MotionEvent.getRawX 和 MotionEvent.getX 的区别 [英] Difference between MotionEvent.getRawX and MotionEvent.getX

查看:23
本文介绍了MotionEvent.getRawX 和 MotionEvent.getX 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 MotionEvent.getRawXMotionEvent.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆