dispatchTouchEvent、onInterceptTouchEvent、onTouchEvent
MotionEvent ev;//down or move or up or others...
viewgroup.dispatchTouchEvent(ev);
public boolean dispatchTouchEvent(MotionEvent ev){
boolean isConsumed = false;
if(onInterceptTouchEvent(ev)){
isCousumed = this.onTouchEvent(ev);
}else{
isConsumed = childView.dispatchTouchEvent(ev);
}
return isConsumed;
}
ViewGroup 中的相关源码:
public boolean dispatchTouchEvent(MotionEvent ev) {
......
// Check for interception.
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;
}
......
}
参考:
未完成...
网友评论