0

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.

Siddharth Kamaria
  • 2,448
  • 2
  • 17
  • 37
  • 1
    Can you disable the viewPager swiping whenever drag-swiping is taking place? And then re-enable it after, of course. – Gavin Wright Aug 27 '20 at 16:30
  • @GavinWright I thought about the same, but for the drag select lib there is only an activation function and nothing for deactivation (which actually makes sense since you drag & select items and you're done!) . Currently I'm experimenting with `ACTION_DOWN` and `ACTION_UP` motion events. – Siddharth Kamaria Aug 27 '20 at 16:54

0 Answers0