Overall understanding of Android touch event processing, android touch

Source: Internet
Author: User
Tags apple event

Overall understanding of Android touch event processing, android touch

First look at several functions:When talking about Android touch event processing, many people will immediately think of some troublesome functions. Here we will list them to stimulate your little nerves:

    @Override    public boolean onTouchEvent(MotionEvent event) {        return super.onTouchEvent(event);    }    @Override    public boolean dispatchTouchEvent(MotionEvent ev) {        return super.dispatchTouchEvent(ev);    }    @Override    public boolean onInterceptTouchEvent(MotionEvent ev) {        return super.onInterceptTouchEvent(ev);    }    @Override    public boolean onTouch(View v, MotionEvent event) {        return false;    }

Well, today, let's take a look at the functions of these four functions and their call relationships to clarify the touch event processing mechanism.

I. Let's take two of them first:

    @Override    public boolean onTouchEvent(MotionEvent event) {        return super.onTouchEvent(event);    }    @Override    public boolean onInterceptTouchEvent(MotionEvent ev) {        return super.onInterceptTouchEvent(ev);    }

1.1 first, it is clear that Android event distribution and processing areTop-downThe first time a touch event is sent to the View on the outermost layer.
1.2 here is an example: we assume that multiple viewgroups in a window form a big family, with the maximum number of views on the outermost layer and the minimum number of views on the innermost layer, then, compare a touch event to an apple event. If an event (an apple is obtained) occurs, the following will happen:

Apple's transfer process:

Grandpa --> dad --> Sun Tzu.

If Grandpa eats the apple, we say the event was consumed.

See:

Further detailed analysis:

So far, is there a general grasp of the message transmission mechanism in Android,
Next, let's clarify some details.

Related Article

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.