android触摸事件分发机制1

2017-06-03  本文已影响12人  Bean的世界

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

上一篇下一篇

猜你喜欢

热点阅读