查看Activity的dispatchTouchEvent方法:
public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { onUserInteraction(); } if (getWindow().superDispatchTouchEvent(ev)) { return true; } return onTouchEvent(ev); }
getWindow().superDispatchTouchEvent(ev)
getWindow()是获取Windowl类唯一子类PhoneWindow的对象
public boolean superDispatchTouchEvent(MotionEvent event) { //mDecor 是PhoneWindow的根布局(FragmentLayout) return mDecor.superDispatchTouchEvent(event); }
所以Activity的事件分发的流程调用ViewGroup的事件分发机制,如果ViewGroup的分发方法返回true,意味着事件被底层View消费了,到此结束。
否则调用自身的onTouchEvent()方法去处理。