I am creating a clickable custom view to replace android.widget.Switch(Switch), using onDraw instead of additional Drawable. When I use Switch previously, if parent is disabled, the Switch is also not clickable, but when I migrated to my custom view, it's still clickable when parent disabled. How can I know if I should disable/ignore clicks?
custom view parent disabled (still clickable!)

Switch parent disabled (not clickable)

my code like...
public class MySwitch extends View {
public boolean onTouchEvent(MotionEvent motionEvent) {
if (isClickable() && isEnabled()) {
//do something
}
}
protected void onDraw(Canvas canvas) {
//draw track and thumb
}
}

You could try validating parent as a
ViewGroupas following.