Onintercepttouchevent Never Receives Action_move
I have a custom ViewGroup with an override of onInterceptTouchEvent(). It receives ACTION_DOWN but never receives ACTION_MOVE. It is my understanding that, unless it returns 'tru
Solution 1:
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.
ACTION_DOWNevent gets dispatched toonInterceptTouchEvent()first. You should returnfalsefrom there.- Now there are two cases:
- If there is no touchable view underneath
ACTION_DONWevent's location in the view tree, thenACTION_DOWNevent and all follow up events get dispatched toonTouchEvent(). You must returntruefrom there. Only then you will receive follow up events sent toonTouchEvent()method. Independently on whether you returntrueorfalse,onInterceptTouchEvent()will not receive any follow up events anymore. - If there is a touchable view, then all events will be dispatched to
onInterceptTouchEvent()(includingACTION_MOVEevents). You need to returntruefrom there, after you detected your gesture. Once you returntruefrom here, touchable view will receiveACTION_CANCELevent and all further events will be dispatched toonTouchEvent()method.
- If there is no touchable view underneath
Hope this helps.
Post a Comment for "Onintercepttouchevent Never Receives Action_move"