Objective:
(1) In Custom view, often encounter event interception processing, such as in the side-slip menu, we would like to have a ListView control in the Slide menu, but we want to both swipe left and right to slide, this time we need to intercept touch events. This time we need to understand the Android touch event delivery mechanism,
(2) before a lot of time is more vague, perhaps the online see also has a lot of related articles, but I look dizzy, explain not thorough, some say half, finally not satisfied, so according to my own understanding to complete the specific is how a delivery way, share to everyone, I hope you can see what is wrong with the correct place in time. Thank you .
To test the layout:
This is the layout file that understands the Android touch event delivery mechanism
Transfer mechanism view:?
?
(1) Android Touch event delivery mechanism, because the Web page causes will be stretched, please separate the diagram in another window open to view.
(2) The event is triggered from the activity and then passed to the layout file, a layer to the sub-container to the bottom of the view, if each layer of layout file does not handle the event or consumption then the event will be from the bottom of the start to upload to activity for consumption.
(3) The event is initiated by the touch event of the activity interface to the layout view, but the view only describes the layout file or view related event passing mechanism, activity events are not described, However, the following tests will involve activity-related event passing to explain some doubts in the mind
Event passing another angle explanation:
(1) Public boolean Dispatchtouchevent (motionevent ev)? distribution touchevent
(2) public boolean Onintercepttouchevent (motionevent ev) intercepts touchevent
(3) public boolean Ontouchevent (motionevent ev) processing touchevent
Second, the Android touch event delivery mechanism can summarize the following rules
(1) An event is triggered by the user clicking the trigger to pass along the direction of the arrow until either end point ends the event pass.
(2) Then the event transmission can be transmitted from a to b,b can not be transmitted to c,b do not distribute, then from B to return a for consumption and then end, can be transmitted from B to C and then pass D, or not to the D for consumption or to the parent container for consumption.
(3) Forget all the previous
?
?
?
?
?
?
Android Touch Event Delivery mechanism