Touch event mechanism

Source: Internet
Author: User

There are only two main characters in touch event distribution: ViewGroup and view. The activity's touch event is actually called the ViewGroup touch event inside it, and can be treated directly as ViewGroup.

View within the ViewGroup, ViewGroup can also be in other viewgroup, this time the internal viewgroup as a view to analyze.

There are only two related events for view: Dispatchtouchevent, Ontouchevent. ViewGroup related events are one more event onintercepttouchevent on the view basis, as long as the viewgroup can respond to the event interception.

The entire viewgroup process can be seen as a touch event looking for a response in a tree structure with viewgroup as the middle node and view as the root node.

1, when the root node receives the touch event, it calls its own Dispatchtouchevent method, distributes the touch event to his child nodes, and if its child node is ViewGroup, continues to be issued;

2. When the touch event reaches view, V calls its own Ontouchevent method via Dispatchtouchevent, returns True if it responds, otherwise returns false;

3, when the ViewGroup child nodes all return false, ViewGroup will call its own Ontouchevent method to try to respond to processing, if successful, return true, otherwise return false, continue upward feedback;

4, until the Response processing node corresponding to the touch event is found, in the process of distribution, if the intermediate node Onintercepttouchevent () method returns True, does not distribute downward, directly calls the Ontouchevent method response of this node

Touch event 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.