Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

What's the exact difference between them?

like image 241
James Avatar asked Mar 09 '11 02:03

James


1 Answers

MotionEvent:

  • 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_CANCEL: The current gesture has been aborted.

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. You can find out more about it at the viewgroup documentation: onInterceptTouchEvent.

so use ACTION_CANCEL when the action is dragged out of the parent, and ACTION_UP otherwise.

like image 196
Ian Avatar answered Oct 17 '22 08:10

Ian