Change RecyclerView scrollBar width
Asked Answered
M

3

7
    <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?

Merce answered 20/7, 2016 at 18:17 Comment(0)
P
14

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!

Plerre answered 13/10, 2016 at 15:53 Comment(0)
B
1

You have one of two oportunities:

1) Change drawable of scrollbar through android:scrollbarThumbVertical="@drawable/yoursdrawablefile

2) Work with scrollbar programmatically through onDrawHorizontalScrollBar and onDrawVerticalScrollBar callbacks.

Please, first two answers of this question for more details.

Bequeath answered 20/7, 2016 at 18:25 Comment(1)
why changing the attribute in xml doesn't work? is it known bug?Merce
E
-1
  1. Horizontal RecyclerView

    android:scrollbars="horizontal"
    android:scrollbarThumbHorizontal="@color/horizontal_color"
    android:scrollbarSize="1dp"
    
  2. Vertical RecyclerView ( default android:scrollbars="vertical")

    android:scrollbarThumbHorizontal="@color/vertical_color"
    android:scrollbarSize="1dp"
    
Evannia answered 27/9, 2018 at 7:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.