我想在启动触摸并离开屏幕后触发一个方法。我可以通过将 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.
关于android - 检测触摸是否在安卓设备屏幕上停止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20639807/