@Override public boolean onElementTouchEvent(MotionEvent event) { // get masked (not specific to a pointer) action float x = getX() + event.getX(); float y = getY() + event.getY(); int action = event.getActionMasked(); switch (action) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_POINTER_DOWN: { movingButton = null; setPressed(true); onClickCallback(); invalidate(); return true; } case MotionEvent.ACTION_MOVE: { checkMovementForAllButtons(x, y); return true; } case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: { setPressed(false); onReleaseCallback(); checkMovementForAllButtons(x, y); invalidate(); return true; } default: { } } return true; }