Android Event distribution mechanism

Source: Internet
Author: User

The  Android event distribution mechanism is a touch event that takes place from one window to another view,

The final process of being consumed in Android is still a more complex delivery process as follows:


(1) The event is passed from Activity.dispatchtouchevent (), as long as it has not been stopped or intercepted, from the top view (viewgroup)

Starts to pass down (sub view). The child view can handle the event through Ontouchevent ().

  
(2) The event is passed by the parent view (ViewGroup) to the child View,viewgroup can intercept the event by Onintercepttouchevent (),

Stop it from passing down.

  
(3) If the event has not been stopped from the top down, and the lowest sub-view has no consumption events, the event will be passed on, the parent view

(ViewGroup) can be consumed, and if it is not consumed, it will eventually go to the activity's ontouchevent () function.

  
(4) If the view does not consume the action_down, then other events will not be passed over.
  
(5) Ontouchlistener takes precedence over ontouchevent () to consume the event.
  
The above consumption means that the corresponding function return value is true.

Android Event distribution mechanism

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.