My current layout has a CoordinatorLayout
, in which I've a TabLayout
connected to a ViewPager2
. Within ViewPager, I have a couple of tabs of RecyclerView
.
<androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.appbar.AppBarLayout ... ">
<androidx.appcompat.widget.Toolbar ... />
<com.google.android.material.tabs.TabLayout
...
app:tabMode="scrollable" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager2.widget.ViewPager2
...
android:clickable="false"
android:longClickable="false"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
My image grid (RecyclerView) uses a RecyclerView.OnItemTouchListener
to implement drag select functionality via this library.
Issue: Drag selection works fine when I use the RecyclerView without the ViewPager2, but as soon as I put the RecyclerView fragment within the view pager, it's swipe gesture starts interfering with the RecyclerView's touch listener.
To confirm the same, I did viewPager.setIsUserInputEnabled(false)
and the drag selection started working but then the view pager swipe no longer works.