Reputation: 21
I want to change the color of scrollbar.
I tried to set in xml like this,
android:scrollbarThumbVertical="@color/blue"
or like this
app:fastScrollVerticalThumbDrawable="@drawable/scroll"
but it's not working.
please let me know if there is a way to change the color , thanks.
To explain more clearly
my code
<androidx.wear.widget.WearableRecyclerView
android:id="@+id/barcodeRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:fadeScrollbars="false"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:scrollbarStyle="insideInset"
android:scrollbarThumbVertical="@drawable/scrollview_thumb"
android:scrollbarTrackVertical="@drawable/vertical_scrollview_track"
android:scrollbars="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
In my emulator, the code upon only change the original scrollBar. If I scroll page, the original scrollBar(which been changed) would disappear and the curved scrollBar would pop up.
original scrollBar(I changed it into blue)
curved scrollBar
Upvotes: 2
Views: 336
Reputation: 510
1. Add following tags in your scrollview
android:fadeScrollbars="false"
android:scrollbarStyle="insideInset"
android:scrollbarThumbVertical="@drawable/scrollview_thumb"
android:scrollbarTrackVertical="@drawable/vertical_scrollview_track"
2. Create following drawable in your drawable folder
scrollview_thumb.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/common_google_signin_btn_text_light_focused" />
<corners android:radius="15dp" />
</shape>
3.vertical_scrollview_traack.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#E2E0EB" />
<stroke
android:width="1dp"
android:color="#b3a9a9" />
<size android:width="15dp" />
<corners android:radius="15dp" />
</shape>
Upvotes: 0