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?
java, getX() obtains the distance between the touch point and the left boundary of the View, and getRawX() obtains the absolute position x value of the touch point in the screen.
Each pointer has a unique id that is assigned when it first goes down (indicated by ACTION_DOWN or ACTION_POINTER_DOWN ). A pointer id remains valid until the pointer eventually goes up (indicated by ACTION_UP or ACTION_POINTER_UP ) or when the gesture is canceled (indicated by ACTION_CANCEL ).
Motion events describe movements in terms of an action code and a set of axis values. The action code specifies the state change that occurred such as a pointer going down or up. The axis values describe the position and other movement properties.
=>
rawX = motionEvent.getX() + touchableButton.getX() + layout3.getX() + layout2.getX();
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With