Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scrollbar color in RecyclerView

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"    /> 
like image 501
Yass Avatar asked Feb 15 '16 00:02

Yass


1 Answers

You can do this by including following line of code in your Recyclerview

android:scrollbarThumbVertical="@drawable/yoursdrawablefile

The drawable file in my case is:

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android">     <gradient android:startColor="#000" android:endColor="#000"         android:angle="45"/>     <corners android:radius="6dp" /> </shape> 
like image 179
Naresh Avatar answered Sep 18 '22 11:09

Naresh