how to create one scrollbar for 3 recyclerView android

Viewed 26

I need to create 1 scrollbar to scroll 3x recyclerView at the same time, i know that it is possible to scroll RView with layoutMatager.scrollTo etc but i dont understand how to make scrollbar

1 Answers

Two things , you need to do.

  1. Wrap up recyclerviews inside nested scrollview.

    <androidx.core.widget.NestedScrollView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:scrollbars="vertical"
         android:fillViewport="true">
    
      //<RecyclerView 1>
      //<RecyclerView 2>
      //<RecyclerView 3>
    
     </androidx.core.widget.NestedScrollView>
    
  2. And then call setNestedScrollingEnabled(false) function to the recyclerview like this while setting adapter.

 recycler1.isNestedScrollingEnabled = false 
 recycler2.isNestedScrollingEnabled = false 
 recycler3.isNestedScrollingEnabled = false
Related