r/android_devs • u/alwaysbakedarjun • Jun 16 '20
Help Nested ViewPager2
I have a view pager with 2 fragments, and the 1 fragment contained another view pager with 3 views and the swipe detections worked fine with the individual swipes on both the view pagers, but then I migrated those view pagers to viewpager2, so the parent viewpager2's adapter is a descendent of fragmentStateAdapter and the child viewpager2's adapter is a descendent of the plain old recycler view adapter, now my swipes have gone for a toss, the inner viewpager2 is not detected at all, only the outer one swipes.
EDIT: Found the solution, go through this https://issuetracker.google.com/issues/123006042
in short, wrap you nested view (recycler view or viewpager2) with this view as a workaround https://github.com/android/views-widgets-samples/blob/master/ViewPager2/app/src/main/java/androidx/viewpager2/integration/testapp/NestedScrollableHost.kt
can go through the sample for better understand.