I am facing a weird issue, I have a Viewpager2, the fragment page contains a Scrollview, HorizontalScrollView, and a RecyclerView.
When I launch the fragment that hosts the ViewPager the UI works, it also works if I swipe right, but as soon as I swipe left to the previous page the touch stops working, I lose the ability to swipe up and down on the page.
I feel lost here, it worked perfectly fine with the old ViewPager
ViewPager fragment page
<ScrollView
android:isScrollContainer="true"
android:measureAllChildren="true"
android:background="?backgroundColor"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
...
</androidx.constraintlayout.widget.ConstraintLayout>
<ScrollView/>
ViewPager
<androidx.viewpager2.widget.ViewPager2
android:orientation="horizontal"
android:id="@+id/pager"
android:layout_width="0dp"
android:layout_height="0dp"
...
/>
I fixed the issue by updating ViewPager's PageTransformer.
I extended ViewPager2.PageTransformer
on my PageTransformer thinking the old transformer would work just fine.
Looks like this is not the case, the old version was missing the translationZ
looks like not setting the translationZ
causes this behavior.