first look at a few functions: mention of the Android Touch event processing, many people will immediately think of some of the headaches of the function, here to list, 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, let's take a look at the function of these four functions and the call relationship between them to clarify the touch event handling mechanism.
First, let's take care of two of them:
@Override publicbooleanonTouchEvent(MotionEvent event) { returnsuper.onTouchEvent(event); } @Override publicbooleanonInterceptTouchEvent(MotionEvent ev) { returnsuper.onInterceptTouchEvent(ev); }
1.1 First make it clear that the Android event distribution and processing is top-down , i.e. a touch event must be sent to the outermost view for the first time.
1.2 Here we give an example: we assume that multiple viewgroup of a window make up a large family, with the outermost view generational the longest, the innermost view generational the smallest, and a touch event is likened to an apple. So, if an event happens (get an apple), the following things will happen:
Apple's transfer process:
Grandpa---papa--grandson.
What if the grandfather ate the apples, then we called the event consumed.
See:
To analyze in detail:
At this point, is not the message delivery mechanism in Android has a whole grasp of it,
Let's find out some details.
Overall grasp of touch event handling in Android