Difference between MotionEvent.getRawX and MotionEvent.getX
Solution 1:
MotionEvent
will sometimes return absolute X and Y coordinates relative to the view, and sometimes relative coordinates to the previous motion event.
getRawX()
and getRawY()
that is guaranteed to return absolute coordinates, relative to the device screen.
While getX()
and getY()
, should return you coordinates, relative to the View, that dispatched them.
Solution 2:
=>
rawX = motionEvent.getX() + touchableButton.getX() + layout3.getX() + layout2.getX();