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

前端 未结 3 1901
夕颜
夕颜 2020-12-14 00:49

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

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-14 01:38

    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.

提交回复
热议问题