android触摸事件分发机制1

Activity->ViewGroup->View   event process


eg:

xml:

code:


TestViewGroup


TestView


touch log:


fenxi log:


MainActivity:dispathTouchEvent  (ActionDown)  

- > TestViewRoot:dispatchTouchEvent  (ActionDown)

->TestViewRoot:onInterceptTouchEvent (ActionDown) 

->TestView:dispathTouchEvent (ActionDown)

->ManActivity:Testview OnTouchListener onTouch  (ActionDown)

->TestView:onTouchEvent  (ActionDown) 

->MainActivity:dispatchTouchEvent (ActionUp)

->TestViewRoot:dispathcTouchEvent (ActionUp)

->TestViewRoot:onInterceptTouchEvent (ActionUp)

->TestView:dispatchTouchEvent (ActionUp)

->MainActivity: TestView onTouchListener onTouch  (ActionUp)

-> TestView:onTouchEvent

->MainAvtivity: TestView onClickListener onClick



if  TestViewRoot:onInterceptTouchEvent  return true;

log below:


MainActivity:dispatchTouchEvent (ActionDown)

->TestViewRoot :dispatchTouchEvent (ActionDown)

->TestViewRoot onInterceptTouchEvent (ActionDown)

-> TestViewRoot onTouchEvent (ActiondonDown)

->MainActivity: onTouchEnvent (ActionDown)

->MainActivity: dispatchTouchEvent (ActionUp)

->MainActivity:onTouchEvent (ActonUp)


we see intercept TestView (view child) touch event



requestDisallowInterceptTouchEvent .   is not work


now we see  Activity dispatchTouchEvent

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容