When ViewPager2 is a child of SwipeRefreshLayout, and you swipe to the next page of the VP2, SRL interrupts the gesture in favor of the swipe-to-refresh gesture if the vertical displacement in the swipe gesture is more then the touch slop.
Hierarchy:
Reproduction path: 1. Use this hierarchy: <swiperefreshlayout> <viewpager2 /> <swiperefreshlayout> 2. Set an adapter on VP2 3. Swipe left and/or right a few times. When the y distance between the swipe start and the current touch location is > touchSlop, the bug is triggered.
Workaround: API >= 21: setNestedScrollingEnabled(true) on the direct child of the SRL API < 21: Let the direct child of SRL implement NestedScrollingChild, and have it set isNestedScrollingEnabled to true. See attached SwipeRefreshChildLayout.kt as a reference implementation, which can be wrapped around the existing child of SRL.
Description
Hierarchy:
Reproduction path:
1. Use this hierarchy:
<swiperefreshlayout>
<viewpager2 />
<swiperefreshlayout>
2. Set an adapter on VP2
3. Swipe left and/or right a few times. When the y distance between the swipe start and the current touch location is > touchSlop, the bug is triggered.
Workaround:
API >= 21: setNestedScrollingEnabled(true) on the direct child of the SRL
API < 21: Let the direct child of SRL implement NestedScrollingChild, and have it set isNestedScrollingEnabled to true. See attached SwipeRefreshChildLayout.kt as a reference implementation, which can be wrapped around the existing child of SRL.