In this tutorial we will learn how to add scrollbar to a recycler view. We will also enable fast scrolling.
Final result:
Lets begin, open your project. Enable appCompat.
![]() |
On your recycleview add below xml code to the view.
Note: inject if you are using sk pro, if you are using android studio or aide add code to recyclerview xml.
CODE:
app:fastScrollEnabled="true"
app:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
app:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
app:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
app:fastScrollVerticalTrackDrawable="@drawable/line_drawable"
Copy and paste above code on inject.
Now let's add the needed resources to draw that scroll bar.
Download the resources below
Extract the file you downloaded (with any app you want)
Go back to your project and go to resources/drawable/
Let's import the files we extracted earlier.
Click the file with a plus (+) on it and locate the extracted files. Pick all four of them.
Note:
These files can be edited to suite the look you want for your scrollbar.
Now go back and run your project. Enjoy.
Sample project can be downloaded below;
0 Comments