美文网首页
android触摸事件分发机制1

android触摸事件分发机制1

作者: Bean的世界 | 来源:发表于2017-06-03 11:57 被阅读12次

    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

    相关文章

      网友评论

          本文标题:android触摸事件分发机制1

          本文链接:https://www.haomeiwen.com/subject/sfwpfxtx.html