Android:ACTION_UP 和 ACTION_POINTER_UP 之间的区别
仅从 android 文档来看,我并不真正理解 ACTION_UP
和 ACTION_POINTER_UP
之间的区别。 http://developer.android.com/reference/android/view/ MotionEvent.html#ACTION_DOWN
基本上我想捕获当一根手指从屏幕上释放时的事件(即使另一根手指可能仍在触摸它)
From the android doc alone I dont really understand the difference between ACTION_UP
and ACTION_POINTER_UP
.
http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_DOWN
Basically I want to capture the event when one finger is released from the screen (even if another one may still be touching it)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您还没有阅读过,请从这里开始: http ://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
Android 根据手势来考虑触摸事件。这种意义上的手势包括从第一根手指触摸屏幕到最后一根手指离开屏幕的所有事件。单个手势的整个事件序列始终发送到在初始
ACTION_DOWN
期间选取的同一视图,除非父级由于某种原因拦截了事件流。如果父进程拦截子进程的事件流,子进程将收到ACTION_CANCEL
。如果您正在处理多点触控事件,请始终使用 getActionMasked() 返回的值来确定操作。如果您不需要多点触控或使用较旧的平台版本,则可以忽略
ACTION_POINTER_*
事件。ACTION_DOWN
适用于触摸屏幕的第一根手指。这将启动手势。该手指的指针数据始终位于 MotionEvent 中的索引 0 处。ACTION_POINTER_DOWN
用于在第一个手指之外进入屏幕的额外手指。该手指的指针数据位于 getActionIndex() 返回的索引处。ACTION_POINTER_UP
。关于抬起的手指的最后一个数据样本位于 getActionIndex() 返回的索引处。ACTION_UP
。关于抬起的手指的最后一个数据样本位于索引 0 处。这将结束手势。ACTION_CANCEL
表示整个手势由于某种原因被中止。手势就此结束。Start here if you haven't read it already: http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
Android thinks about touch events in terms of gestures. A gesture in this sense includes all events from the first finger that touches the screen to the last finger that leaves the screen. A single gesture's entire event sequence is always sent to the same view that was picked during the initial
ACTION_DOWN
unless a parent intercepts the event stream for some reason. If a parent intercepts a child's event stream, the child will getACTION_CANCEL
.If you're working with multitouch events, always use the value returned by getActionMasked() to determine the action. If you don't need multitouch or are working with an older platform version, you can ignore the
ACTION_POINTER_*
events.ACTION_DOWN
is for the first finger that touches the screen. This starts the gesture. The pointer data for this finger is always at index 0 in the MotionEvent.ACTION_POINTER_DOWN
is for extra fingers that enter the screen beyond the first. The pointer data for this finger is at the index returned by getActionIndex().ACTION_POINTER_UP
is sent when a finger leaves the screen but at least one finger is still touching it. The last data sample about the finger that went up is at the index returned by getActionIndex().ACTION_UP
is sent when the last finger leaves the screen. The last data sample about the finger that went up is at index 0. This ends the gesture.ACTION_CANCEL
means the entire gesture was aborted for some reason. This ends the gesture.我相信它源于多点触控的添加,
ACTION_UP
自 API Level 1 以来就已经存在,但ACTION_POINTER_UP
是在添加多点触控时在 API Level 5 中添加的。您获得的结果将取决于您调用的方法,
getAction()
将返回ACTION_UP
,而getActionMasked()
将返回ACTION_POINTER_UP
还允许您调用getActionIndex()
来找出刚刚引发了哪个多点触摸指针。我想这就是你想做的。I believe it stemmed from Multi-touch being added in,
ACTION_UP
has been in since API Level 1, butACTION_POINTER_UP
was added in API Level 5 when multi-touch was added.The result you get will depend on which method you are calling,
getAction()
would returnACTION_UP
whereasgetActionMasked()
would giveACTION_POINTER_UP
but also allow you to callgetActionIndex()
to find out which of the multi-touch pointers has just been raised. I think this is what you want to do.