onInterceptTouchEvent never receives action_move

為{幸葍}努か 提交于 2019-12-03 08:56:30

It's a bit more complicated than that. First of all you need to override onTouchEvent() and handle ACTION_DOWN and MOVE events there too. Then the following will happen.

  1. ACTION_DOWN event gets dispatched to onInterceptTouchEvent() first. You should return false from there.
  2. Now there are two cases:
    • If there is no touchable view underneath ACTION_DONW event's location in the view tree, then ACTION_DOWN event and all follow up events get dispatched to onTouchEvent(). You must return true from there. Only then you will receive follow up events sent to onTouchEvent() method. Independently on whether you return true or false, onInterceptTouchEvent() will not receive any follow up events anymore.
    • If there is a touchable view, then all events will be dispatched to onInterceptTouchEvent() (including ACTION_MOVE events). You need to return true from there, after you detected your gesture. Once you return true from here, touchable view will receive ACTION_CANCEL event and all further events will be dispatched to onTouchEvent() method.

Hope this helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!