MotionEvent.getRawX 和 MotionEvent.getX 的区别 [英] Difference between MotionEvent.getRawX and MotionEvent.getX
问题描述
我想知道 MotionEvent.getRawX
和 MotionEvent.getX
在 android 中的区别,一个是数字,另一个是浮点数?有什么需要同时拥有这些类型?
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?
推荐答案
MotionEvent
有时会返回相对于视图的绝对 X 和 Y 坐标,有时会返回相对于前一个运动事件的相对坐标.
MotionEvent
will sometimes return absolute X and Y coordinates relative to the view, and sometimes relative coordinates to the previous motion event.
getRawX()
和 getRawY()
保证返回相对于设备屏幕的绝对坐标.
getRawX()
and getRawY()
that is guaranteed to return absolute coordinates, relative to the device screen.
虽然 getX()
和 getY()
应该返回相对于派遣它们的视图的坐标.
While getX()
and getY()
, should return you coordinates, relative to the View, that dispatched them.
这篇关于MotionEvent.getRawX 和 MotionEvent.getX 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!