其他分享
首页 > 其他分享> > 检测触摸是否在Android设备屏幕上停止

检测触摸是否在Android设备屏幕上停止

作者:互联网

我想在启动触摸并离开屏幕后触发方法.我可以通过将OnTouch事件设置为View来检测触摸的开始,但无法检测到手离开屏幕的时间.我想检测触摸何时停止.我怎么能发现这个?

解决方法:

您正在寻找的是http://developer.android.com/reference/android/view/MotionEvent.html – 特别是使用MotionEvent.ACTION_UP.关于我提供的链接有很多信息:)

A gesture starts with a motion event with ACTION_DOWN that provides the location of the first pointer down. As each additional pointer that goes down or up, the framework will generate a motion event with ACTION_POINTER_DOWN or ACTION_POINTER_UP accordingly. Pointer movements are described by motion events with ACTION_MOVE. Finally, a gesture end either when the final pointer goes up as represented by a motion event with ACTION_UP or when gesture is canceled with ACTION_CANCEL.

标签:motionevent,android,motion-detection
来源: https://codeday.me/bug/20190831/1774141.html