How do I know if a MotionEvent is relative or absolute?

PeyloW picture PeyloW · Sep 11, 2009 · Viewed 21.5k times · Source

I am implementing OnTouchListener and am receiving MotionEvent objects. Some ACTION_MOVE events reports absolute X/Y coordinates, while some reports relative coordinates.

How can I ask a MotionEvent what kind of coordinates it currently represents?

Answer

Dimitar Dimitrov picture Dimitar Dimitrov · Sep 12, 2009

You may want to use these for absolute coordinates (absolute, regarding the screen of the device):

MotionEvent.getRawX()

MotionEvent.getRawY()

The other methods, getX() and getY(), should return you coordinates relative to the View that dispatched them.