Question

I have a simple layout:

<CustomFrameLayout>
    <ListView />
</CustomFrameLayout>

In my CustomFrameLayout, I am overriding:

onInterceptTouchEvent(MotionEvent event);

and returning false. When scrolling the ListView, the onInterceptTouchEvent receives the ACTION_DOWN and the first ACTION_MOVE event. Then, the ListView seems to take over and onInterceptTouchEvent fails to receive the following ACTION_MOVE events.

This goes against what the documentation states:

For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().

http://developer.android.com/reference/android/view/ViewGroup.html#onInterceptTouchEvent(android.view.MotionEvent)

I have looked into requesting touch events to not be intercepted at the ListView level.

requestDisallowInterceptTouchEvent(boolean disallowIntercept)

This does not seem to have any effect. Should I be calling this on the ListView cell view's as well? Is there something else I am missing? I am testing on Android 4.4

Thanks.

Was it helpful?

Solution 2

I have decided to override this method instead. Here, I can guarantee that I can intercept all touch events before they are dispatched to and potentially consumed by the child views.

dispatchTouchEvents(MotionEvent event);

OTHER TIPS

you should return true in onInterceptTouchEvent(MotionEvent event);

true indicates that you are willing to receive further touch actions where as false indicates you are not interested further actions...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top