Reprint Please specify source: http://blog.csdn.net/ZhouLi_CSDN/article/details/45878337
Read so many blogs on the internet, the handling of the events of the Android system is still not very clear, or some of the blog is always a little ambiguous or incorrect or incomplete. So I summed up the event of the transmission mechanism hope to help the vast number of friends.
- Assume that the event routing path is a-b-c-d-e;
- A gesture is a collection of other events, such as events Action_down start and action_move, and the end of events action_up;
- A action_down means the beginning of a new gesture, aciton_up means the end of a gesture;
- The event begins with the dispatchevent of the activity, and is passed down by calling the dispatchevent of the child view (including ViewGroup) until it is a view;
- The event is then passed up from the lowest view, processed by Ontouchevent and passed to the activity's ontouchevent;
- The first thing the framework layer handles is the Action_down event, which is passed to the lowest level if the event is not oninterceptevent during delivery (returns true to block);
- At this point the event will begin to pass from the bottom up, and if a layer (assuming D) is consumed on the way (that is, Ontouchevent returns True), then this event will terminate the pass-up, And later events will be processed directly by the Dispatchevent method of D (Ontouchevent method) (Event delivery order a-b-c-d);
- If no ontouchevent are consumed during the pass, then this event will be processed directly by the activity's ontouchevent. This means that if you want to handle gestures at a certain level, it is important that you consume action_down at that level to ensure that events can be received later.
- Action_down event processing will begin processing of other events (all events except Action_down);
- Depending on your gesture processing logic, you can always decide whether to terminate the pass-through event at any time in a layer of oninterceptevent, and you will never be able to pass the event down after Oninterceptevent.
- Requestdisallowintercepttouchevent will prevent ViewGroup from interrupting the event;
- If an event is processed and consumed in a layer ontouchevent, the event will not be passed up, otherwise it will continue to pass up.
Other Knowledge Introduction:
The Viewconfiguration class holds a number of constants that are generated by the framework layer for us.
1. Where getscaledtouchslop determines whether the slide
2.fling, whether fast sliding
3. Other self-study go.
At present first introduced here, follow-up in the update!
Android Touch event distribution mechanism