• onInterceptTouchEvent / onTouchEvent响应事件的详析


    onInterceptTouchEvent(),onTouchEvent() 默认返回false

    注:事件分发机制是由 dispatchTouchEvent() 开始分发的

    onInterceptTouchEvent()

    ACTION_DOWN ------------ return true: ---→  将事件传递给该view下的 onTouchEvent()                                                                                                                                                                                                                                                                                                                          ACTION_MOVE ACTION_UP 都将直接由 onTouchEvent() 响应                                                                      

                                                                            该view的 onInterceptTouchEvent() 将无法响应 ACTION_MOVE,ACTION_UP

                                ------------ return false:    ↓   将事件向下传递(判断是否存在下级)

                                                                  无下级: 将事件传递给该view下的 onTouchEvent()(等同于返回true)

                                                                  有下级: 判断下一级是View 还是 ViewGroup

                                                                               ViewGroup : 将事件传递给下一级的 onInterceptTouchEvent(),一直向下传递

                                                                               View: 将事件传递给下一级的 onTouchEvent()

                                                                   ACTION_MOVE ,ACTION_UP 都将由第一级别的 onInterceptTouchEvent() 响应

                                                                                                  return false: 将ACTION_MOVE 事件传递给下一级的 onInterceptTouchEvent() ,以此类推

                                                                                                  return true:   将ACTION_CANCEL 事件传递给 下面级别的所有响应 ACTION_DOWN 事件的方法,

                                                                                                                      将ACTION_MOVE 事件传递给此view 的onTouchEvent() ,所以接下来的action(ACTION_MOVE,ACTION_UP)都将按照这个顺序传递

    onTouchEvent()

    ACTION_DOWN ------------- return true: ---→  判断是否存在上级

                                                                   无上级:将事件传递给下面的action(响应 ACTION_MOVE,ACTION_UP)

                              ACTION_MOVE,ACTION_UP: 将直接由 onTouchEvent() 响应

                                                                   有上级:将事件传递给 第一级 onInterceptTouchEvent() 来响应 ACTION_MOVE,ACTION_UP 事件

                                                                                 第一级的onInterceptTouchEvent() 响应了ACTION_MOVE 事件后 

                                                                                                                     return false: 将ACTION_MOVE 事件传递给下一级的 onInterceptTouchEvent() ,以此类推

                                                                                                                     return true:   将ACTION_CANCEL 事件传递给 下面级别的所有响应 ACTION_DOWN 事件的方法

                                                                                                                                          将ACTION_MOVE 事件传递给此view 的onTouchEvent() ,所以接下来的action(ACTION_MOVE,ACTION_UP)都将按照这个顺序传递

                                                                                                                                       

                                ------------- return false:    ↑    将事件向上传递(判断是否存在上级)

                                                                   无上级:事件终止  X

                                                                   有上级:事件传递给上一级的 onTouchEvent()

    onTouchEvent()

  • 相关阅读:
    oracle级联删除
    sqlserver 中批量删除 换行符
    SpringBoot与jackson.databind兼容报错问题
    mvn 本地jar包 加入自己的maven仓库
    sql server 表2字段更新到表1,mysql
    sql server 修改表字段
    Spring Boot文件上传
    java如何实现多继承(实现:子类中二个方法,分别继承不同父类)
    SQL SERVER 数据库如何限制一列不能重复(已经有主键)
    SQL server 字段合并CAST(org_no AS VARCHAR(20))+CAST(page_no AS VARCHAR(20))+CAST(djlb_no AS VARCHAR(20)))
  • 原文地址:https://www.cnblogs.com/zhy7104/p/6023961.html
Copyright © 2020-2023  润新知