First, Touch incident analysis
***************************************************************************************************************
Event Distribution: Public boolean dispatchtouchevent (motionevent ev)
When the Touch event occurs, the Dispatchtouchevent (motionevent ev) method of the Activity passes the event to the outermost layer by tunneling (passing from the root element down to the topmost child element or in an intermediate element because a condition stops passing). View's dispatchtouchevent (motionevent ev) method, and the event is distributed by the view's dispatchtouchevent (Motionevent ev) method. The event distribution logic for Dispatchtouchevent is as follows:
If return true, the event is distributed to the current View and consumed by the Dispatchtouchevent method, while the event stops passing down;
If return is false, event distribution is divided into two scenarios:
If the current View gets events directly from the activity, the event is returned to the activity's ontouchevent for consumption;
If the current view gets an event from the outer parent control, the event is returned to the parent view's ontouchevent for consumption.
If the system default super.dispatchtouchevent (EV) is returned, the event is automatically distributed to the current View's Onintercepttouchevent method.
***************************************************************************************************************
Event interception: Public boolean onintercepttouchevent (motionevent ev)
When the dispatchtouchevent (motionevent ev) method of the outer view returns to the system's default super.dispatchtouchevent (EV) case, the event is automatically distributed to the current view's Onintercepttouchevent method. The Onintercepttouchevent event interception logic is as follows:
If Onintercepttouchevent returns True, the event is intercepted and the intercepted event is referred to the current View's ontouchevent for processing;
If Onintercepttouchevent returns FALSE, the event is released, the event on the current view is passed to the child view, and then the dispatchtouchevent of the view begins the distribution of the event;
If Onintercepttouchevent returns super.onintercepttouchevent (EV) and returns false as the processing logic.
***************************************************************************************************************
Event Response: Public boolean ontouchevent (motionevent ev)
The Dispatchtouchevent returns super.dispatchtouchevent (EV) and onintercepttouchevent returns TRUE or returns Super.onintercepttouchevent ( EV), the ontouchevent will be called. The event response logic for Ontouchevent is as follows:
If the event is passed to the current view's Ontouchevent method, and the method returns False, the event is passed up from the current view and is received by the ontouchevent of the upper view, if passed to the ontouchevent above Also returns false, the event "disappears" and the next event is not received.
If True is returned, the event is received and consumed.
If the return super.ontouchevent (EV) default handles the logic of the event and returns false, the same.
The distribution and consumption mechanism of Touch events under Android programming