Android事件分发机制

ViewTestActivity   dispatchTouchEvent
2020-03-06 19:21:45.460 18720-18720/com.example.hp.hencoderstudy E/tag: MyVIewGroup1   dispatchTouchEvent
2020-03-06 19:21:45.460 18720-18720/com.example.hp.hencoderstudy E/tag: MyVIewGroup1   onInterceptTouchEvent
2020-03-06 19:21:45.460 18720-18720/com.example.hp.hencoderstudy E/tag: MyVIewGroup2   dispatchTouchEvent
2020-03-06 19:21:45.460 18720-18720/com.example.hp.hencoderstudy E/tag: MyVIewGroup2   onInterceptTouchEvent
2020-03-06 19:21:45.460 18720-18720/com.example.hp.hencoderstudy E/tag: MyVIew1   dispatchTouchEvent
2020-03-06 19:21:45.460 18720-18720/com.example.hp.hencoderstudy E/tag: MyVIew1   onTouchEvent
2020-03-06 19:21:45.460 18720-18720/com.example.hp.hencoderstudy E/tag: MyVIewGroup2   onTouchEvent
2020-03-06 19:21:45.460 18720-18720/com.example.hp.hencoderstudy E/tag: MyVIewGroup1   onTouchEvent
2020-03-06 19:21:45.461 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   onTouchEvent
2020-03-06 19:21:45.485 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   dispatchTouchEvent
2020-03-06 19:21:45.486 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   onTouchEvent
2020-03-06 19:21:45.535 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   dispatchTouchEvent
2020-03-06 19:21:45.536 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   onTouchEvent
2020-03-06 19:21:45.546 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   dispatchTouchEvent
2020-03-06 19:21:45.547 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   onTouchEvent
2020-03-06 19:21:45.547 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   dispatchTouchEvent
2020-03-06 19:21:45.547 18720-18720/com.example.hp.hencoderstudy E/tag: ViewTestActivity   onTouchEvent

ViewGroup 没有onTouchEnent实现,在View中
VIewoGroup dispatchTouchEvent
1.去判断是否去拦截
2在当前VieGroup找到真正的View
3.时间分发到View上


微信图片_20200306192424.png

微信图片_20200306192432.png
微信图片_20200306192436.png

你可能感兴趣的:(Android事件分发机制)