我怎么知道,如果一个MotionEvent是相对的还是绝对的? [英] How do I know if a MotionEvent is relative or absolute?

查看:136
本文介绍了我怎么知道,如果一个MotionEvent是相对的还是绝对的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在执行 OnTouchListener 和我收到MotionEvent对象。有些 ACTION_MOVE 事件报告绝对X / Y坐标,而有些报告的相对坐标。

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

我怎么能问一个 MotionEvent 什么样的​​坐标是目前重新presents?

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

推荐答案

您可能需要使用这些绝对坐标(绝对的,对于设备的屏幕):

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

<一个href="http://developer.android.com/reference/android/view/MotionEvent.html#getRawX%28%29">MotionEvent.getRawX()

<一个href="http://developer.android.com/reference/android/view/MotionEvent.html#getRawY%28%29">MotionEvent.getRawY()

其他方法,的getX() getY()以,应该返回你的坐标,​​相对于查看,分派他们。

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

这篇关于我怎么知道,如果一个MotionEvent是相对的还是绝对的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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