[英]What's the difference between ACTION_CANCEL and ACTION_UP in MotionEvent?
I want to track a finger touch on the screen. 我想跟踪屏幕上的手指触摸。 So what I did was to start recording the position when
MotionEvent
triggers ACTION_DOWN
, but how do I know when the action is finished, at ACTION_CANCEL
, or ACTION_UP
? 所以我所做的就是开始录制时的位置
MotionEvent
触发ACTION_DOWN
,但我怎么知道什么时候该动作完成,在ACTION_CANCEL
,或ACTION_UP
?
What's the exact difference between them? 它们之间的确切区别是什么?
ACTION_UP: A pressed gesture has finished, the motion contains the final release location as well as any intermediate points since the last down or move event. ACTION_UP:按下的手势已完成,该动作包含最终的释放位置以及自上次下移或移动事件以来的任何中间点。
ACTION_CANCEL: The current gesture has been aborted. ACTION_CANCEL:当前手势已中止。
ACTION_CANCEL occurs when the parent takes possession of the motion, for example when the user has dragged enough across a list view that it will start scrolling instead of letting you press the buttons inside of it. ACTION_CANCEL在父级控制动作时发生,例如,当用户在列表视图中拖动足够多以使其开始滚动而不是让您按下其内部的按钮时,就会发生。 You can find out more about it at the viewgroup documentation: onInterceptTouchEvent .
您可以在视图组文档中找到有关它的更多信息: onInterceptTouchEvent 。
so use ACTION_CANCEL when the action is dragged out of the parent, and ACTION_UP otherwise. 因此,当操作从父级中拖出时,请使用ACTION_CANCEL;否则,请使用ACTION_UP。
In general ACTION_UP
is triggered by user when the guest is finished to definitely indicate that the user completed interacting with movement. 通常,当访客完成时,用户触发
ACTION_UP
以明确指示用户完成了与移动的交互。
On the other hand ACTION_CANCEL
is called by system to show that a parent view takes over control of one of its children views. 另一方面,系统调用
ACTION_CANCEL
以显示父视图接管其子视图之一的控制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.