The "Android Development Pit Series" event

Source: Internet
Author: User

To summarize:

There are only two main characters in 1.Touch event distribution:
ViewGroup and view.
ViewGroup contains three related events for Onintercepttouchevent, Dispatchtouchevent, Ontouchevent. View contains Dispatchtouchevent, ontouchevent two related events. Where ViewGroup is inherited from view.

2. Touch events consist of Action_down, Action_move, Aciton_up, and in one complete touch event, down and up are only a maximum of one, and the Move has several, which can be 0.

3. Two ways to pass the event:
tunnel mode : passes from the root element down to the most inner child element or in an intermediate element because a condition stops passing;
bubbling : passes outward from the most inner child element to the root element or to an element in the middle because a condition stops passing.
Dispatchtouchevent is the tunnel mode, Ontouchevent is the bubbling mode (if true, the upper layer is no longer processed).

4. Onintercepttouchevent has two functions:
Interception of the distribution of down events;
Aborts the up and move events to the target view, allowing the viewgroup of the target view to capture the up and move events.

Reference: "Android event distribution mechanism fully resolved, take you from the point of view of the source of the thorough understanding"

The "Android Development Pit Series" event

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.