Android MotionEvent.getRawX 和 MotionEvent.getX 的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20636163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between MotionEvent.getRawX and MotionEvent.getX
提问by Laura Stone
I would like to know The difference between MotionEvent.getRawXand MotionEvent.getXin android as one is numeric and the other is float?Whats the need to have both of these types?
我想知道androidMotionEvent.getRawX和MotionEvent.getXandroid之间的区别,一个是数字,另一个是浮点数?需要同时拥有这两种类型吗?
回答by Piyush
MotionEventwill sometimes return absolute X and Y coordinates relative to the view, and sometimes relative coordinates to the previous motion event.
MotionEvent有时会返回相对于视图的绝对 X 和 Y 坐标,有时会返回前一个运动事件的相对坐标。
getRawX()and getRawY()that is guaranteed to return absolute coordinates, relative to the device screen.
getRawX()并且getRawY()保证返回相对于设备屏幕的绝对坐标。
While getX()and getY(), should return you coordinates, relative to the View, that dispatched them.
而getX()and getY(),应该返回您相对于派遣它们的视图的坐标。


