1,android中点击事件分发主要涉及三个方法:dispatchTouchEvent、onInterceptTouchEvent、onTouchEvent。
dispatchTouchEvent负责点击事件的分发;onInterceptTouchEvent负责点击事件的拦截;onTouchEvent消费具体的点击事件。
2,Activity中有两个方法:dispatchTouchEvent、onTouchEvent;
ViewGroup中存在三个方法:dispatchTouchEvent、onInterceptTouchEvent、onTouchEvent;
View中存在两个方法:dispatchTouchEvent、onTouchEvent。
3,事件传递的顺序为:
dispatchTouchEvent的传递顺序为:Activity --> ViewGroup -->View;
onTouchEvent的执行顺序为:View --> ViewGroup --> Activity;
onInterceptTouchEvent的作用为拦截点击事件的传递,如果onInterceptTouchEvent返回true,则会直接调用该ViewGroup的onTouchEvent方法,子view无法获取到点击事件。
4,事件传递的记忆:针对一次点击事件,事件传递会按照action_down的传递路径就行传递。