Change RecyclerView scrollBar width

q126y picture q126y · Jul 20, 2016 · Viewed 7.7k times · Source
    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ddd"
        android:fadeScrollbars="true"
        android:scrollbarSize="12dp"
        android:orientation="vertical"
        android:scrollbars="vertical"/>

I am testing the code on 5.1.1. Changing android:scrollbarSize has no effect. I tried increasing and decreasing it, no change.

How to change the width?

Answer

Evan picture Evan · Oct 13, 2016

Now, I tell you a method,you can try it and then you will know the answer: add the following codes:

android:scrollbarThumbVertical="@color/colorAccent"

the whole block like this:

 <android.support.v7.widget.RecyclerView
    android:id="@+id/RV_hot_latest"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:scrollbars="vertical"
    android:scrollbarThumbVertical="@color/colorAccent"
    android:scrollbarSize="18dp"
    android:scrollbarStyle="outsideInset"/>

Now ,you will find you android:scrollbarSize has effect. Good luck!