How can I change the color of my scrollbar in a recyclerView?
I have the scrollbar but I want to change its color. My recyclerView is like this:
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recyclerView"
android:layout_below="@id/my_toolbar"
android:layout_above="@+id/progressBar"
android:scrollbars="vertical"
/>
In case you want to further style your scrollbars, create two drawable resource file in your drawable folder as 1. scrollbar_track and 2. scrollbar_thumb
scrollbar_track.xml
scrollbar_thumb.xml
Now, create a style named scrollbar_style in your
styles.xml
file as:Finally, to apply this style to the scrollbar in your recyclerview, add
style="@style/scrollbar_style"
to your recyclerview.
In your case:
You can do this by including following line of code in your Recyclerview
android:scrollbarThumbVertical="@drawable/yoursdrawablefile
The drawable file in my case is:
If you need to change the color in runtime, this is the way.
These methods are defined in View class, so the same princible should work of other views like ScrollView and ListView.