During app development, custom controls are often required to handle Touch events. This article describes how the Android Application Layer distributes Touch events.
In general, the distribution of Touch events follows the "V" structure, as shown in (the figure is a bit rough:-D ): <Strong? Http: www.bkjia.com kf ware vc "target =" _ blank "class =" keylink "> VcD4KPHA + pgltzybzcm9 "http://www.bkjia.com/uploadfile/Collfiles/20140116/20140116134632289.jpg" alt = "\">
The relationship between View and ViewGroup is as follows:
There are three main points:
1. The outer ViewGroup receives the event first. ViewGroup calls intercept in dispatch to determine the distribution direction. If intercept returns true, it distributes the event to the inner control. Otherwise, it distributes the event directly to its own touch function.
2. the return value of the touch function determines whether the event will continue to be transmitted. If true is returned, the event will be consumed and will not be passed back. Otherwise, the event will be passed back.
3. The final return value of an event determines whether the subsequent event is received. If the Activity and the touch function of all controls do not consume the event (true is returned by touch), the subsequent event is no longer received; otherwise, the system continues to receive subsequent events.
The left side of the "V" font is the dispatch function. The inflection point below is the touch function of the inner View, and the touch function of the outer View on the right. Of course, the innermost layer is a ViewGroup.