Difference between MotionEvent.getRawX and MotionEvent.getX
AndroidAndroid LayoutAndroid UiAndroid Problem Overview
I would like to know The difference between MotionEvent.getRawX
and MotionEvent.getX
in android as one is numeric and the other is float?Whats the need to have both of these types?
Android Solutions
Solution 1 - Android
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.