dispatchTouchEvent 方法可以根据DOWN事件和move,up事件分别分析。本文章不考虑多触摸点,TouchTarget链是储存了多触摸点,pointerIdBits 属性表示触摸点Id
1.DOWN事件,主要作用是确定消费路线(把处理事件的View赋值给mFirstTouchTarget)
dispatchTouchEvent方法的简要代码
final boolean intercepted;
if (actionMasked == MotionEvent.ACTION_DOWN
|| mFirstTouchTarget != null) {
final boolean disallowIntercept = (mGroupFlags & FLAG_DISALLOW_INTERCEPT) != 0;
if (!disallowIntercept) {
intercepted = onInterceptTouchEvent(ev);
ev.setAction(action); // restore action in case it was changed
} else {
intercepted = false;
}
} else {
// There are no touch targets and this action is not an initial down
// so this view group continues to intercept touches.
intercepted = true;
}
if (!canceled && !intercepted){
//Down事件
if (actionMasked == MotionEvent.ACTION_DOWN
|| (split