识别来自 MotionEvent 流的点击
有没有办法在 Android 中检测来自 MotionEvent
的点击?更具体地说,我需要一种方法来区分两种事件:移动和点击(我对后者更感兴趣)。
例如,可以在 MapView 组件中观察到这种行为:如果您稍微拖动地图 - 它不会移动(我将其称为单击),但是如果移动距离较大,地图也开始移动(我称之为运动)。是否有标准阈值(全局参数)或其他方法来区分这两个操作?
Is there a way to detect a click from MotionEvent
s in Android? To be more specific, I need a way to distinct two kind of events: movement and click (I'm more interested in the latter).
For example, this kind of behavior can be observed in MapView
component: if you drag the map just a little - it does not move (I would call this a click), however if movement distance is bigger the map starts to move as well (I would call this movement). Is there a standard threshold (global parameter) or other method to distinct these two actions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以实现 OnGestureListener。
onSingleTapUp()
将针对点击类型事件调用,onScroll()
将针对移动类型事件调用。You can implement an OnGestureListener.
onSingleTapUp()
will be called for a click type event andonScroll()
will be called for a movement type event.