android触摸事件分发机制1

Activity->ViewGroup->View   event process


eg:

xml:

android触摸事件分发机制1_第1张图片

code:


android触摸事件分发机制1_第2张图片

TestViewGroup


android触摸事件分发机制1_第3张图片

TestView


android触摸事件分发机制1_第4张图片

touch log:


fenxi log:


android触摸事件分发机制1_第5张图片

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:


android触摸事件分发机制1_第6张图片

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

你可能感兴趣的:(android触摸事件分发机制1)