事件因素:Activity --> ViewGroup --> View
一、Activity中拦截事件
1,Activity_dispatch拦截,返回false的情况
Activity_dispatch --> DOWN / UP / MOVE --> 分发结束
2,Activity_dispatch拦截,返回true的情况
Activity_dispatch --> DOWN / UP / MOVE --> 分发结束
3,Activity_onTouchEvent拦截,返回false的情况
(DOWN事件) Activity_dispatch --> ViewGroup_dispatch --> Activity_onTouchEvent --> 分发结束
(MOVE / UP事件,ViewGroup_dispatch将不再执行) Activity_dispatch --> Activity_onTouchEvent --> 分发结束
4,Activity_onTouchEvent拦截,返回true的情况
(DOWN事件) Activity_dispatch --> ViewGroup_dispatch --> Activity_onTouchEvent --> 分发结束
(MOVE / UP事件,ViewGroup_dispatch将不再执行) Activity_dispatch --> Activity_onTouchEvent --> 分发结束
二、ViewGroup中拦截事件
1,ViewGroup_dispatch 拦截,返回false的情况
(DOWN事件) Activity_dispatch --> ViewGroup_dispatch --> Activity_onTouchEvent --> 分发结束
(MOVE / UP事件,ViewGroup_dispatch将不再执行) Activity_dispatch --> Activity_onTouchEvent --> 分发结束
2,ViewGroup_dispatch 拦截,返回true的情况
(DOWN事件) Activity_dispatch --> ViewGroup_dispatch --> 分发结束
(MOVE / UP事件) Activity_dispatch --> ViewGroup_dispatch --> 分发结束
3,ViewGroup_intercept 拦截,返回false的情况(默认)
(DOWN / UP / MOVE) Activity_dispatch --> ViewGroup_dispatch --> ViewGroup_onIntercept --> View_dispatch --> View_onTouchEvent --> 分发结束
4,ViewGroup_intercept 拦截,返回true的情况(默认)
(DOWN事件) Activity_dispatch --> ViewGroup_dispatch --> ViewGroup_onIntercept --> ViewGroup_onTouchEvent --> 分发结束
(MOVE / UP 事件,ViewGroup_onIntercept返回true后,不再调用) Activity_dispatch --> ViewGroup_dispatch --> ViewGroup_onTouchEvent --> 分发结束
5,ViewGroup_intercept 根据条件判断拦截,不拦截DOWN事件,拦截MOVE事件
(DOWN事件) Activity_dispatch --> ViewGroup_dispatch --> ViewGroup_onIntercept --> View_dispatch --> View_onTouchEvent --> 分发结束
(首次 MOVE事件拦截,此次事件分发,虽然拦截了MOVE事件,但还会继续下发。不同之处在于,view接收到的事件不是MOVE而是CANCLE)
Activity_dispatch --> ViewGroup_dispatch --> ViewGroup_onIntercept --> View_dispatch --> View_onTouchEvent --> 分发结束
(再次 MOVE事件拦截,ViewGroup_onIntercept将不再调用)
Activity_dispatch --> ViewGroup_dispatch --> ViewGroup_onTouchEvent -- > 分发结束
6,UP事件一般不做拦截。