Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ListView's ScrollBar/FastScroll color?

My app has an orange theme all over but the ScrollBar/FastScroll is appearing green. I've tried to search a lot but can't find any way to change this. It just stays the way it is.

I found a "android:fastScrollTextColor" property but that changes the color of the B inside the bubble. And I can't find any property to change the color of this bubble or the ScrollBar next to it.

Snapshot

In case it makes a difference I'm using the custom PinnedHeaderListView that I got from here to mimic the sticky headers in the lollipop contacts app.

like image 271
Ronak Manglani Avatar asked Jun 01 '15 14:06

Ronak Manglani


2 Answers

Scrollbar thumb color is set to the android:colorAccent attribute in your app theme. You are sure that is set and is correct, right?

Note that if you're using AppCompat, you will have to exclude the android: prefix from the attribute.

You can find more information on available color attributes here.

like image 109
xip Avatar answered Nov 15 '22 04:11

xip


set This in your listView attributes in xml file.

android:scrollbarSize="10dp"
android:scrollbarThumbVertical="@drawable/custom_scroll_style"

Here custom_scroll_style is a xml file under the drawable folder. Lets create the custom_scroll_style.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" >

<gradient
    android:angle="45"
    android:endColor="@color/endColor" //define what you want
    android:centerColor="@color/centercolor"
    android:startColor="@color/startColor" />

<corners android:radius="8dp" />
<size android:width="4dp"/>
<padding
    android:left="0.5dp"
    android:right="0.5dp" />

</shape>

Hope it helps!

like image 34
Ajay P. Prajapati Avatar answered Nov 15 '22 02:11

Ajay P. Prajapati