konrad_sx
konrad_sx

Reputation: 485

Swipe in ViewPager2 not working while nested ScrollView is fling-scrolling

I have a ViewPager2 with default horizontal swipe-navigaton. Each "page" has a ScrollView so that content can be scrolled vertically. Normally this works well: When the touch movement starts horizontally it is handled by the ViewPager, when it starts vertically it is handled by the ScrollView.

However after a vertical fling gesture, while the ScrollView is scrolling on its own, any touch movement is handled by the ScrollView, whether it starts horizontally or vertically. So users first have to stop the fling before they can swipe to the next page. How can I change this?

In the Gmail app, when swiping between mails, the behaviour is as I expect it.

Upvotes: 1

Views: 1560

Answers (1)

konrad_sx
konrad_sx

Reputation: 485

I finally found a simple solution. I override onInterceptTouchEvent of a parent view of the ViewPager2, there on ACTION_DOWN, I stop the fling of the ScrollView with fling(0).

Upvotes: 1

Related Questions