Change scrollbar color in Android

Can I change the color or appearance of a scrollbar in a ScrollView or ListView?

+43
android listview scrollview
Jun 18 '10 at 15:41
source share
2 answers

Check out the ApiDemos sample design in the SDK. The res/layout/scrollbar2.xml shows how to style scrollbars.

There are separate attributes for the scroll bar track and thumb scroll bar. Size can also be adjusted.

+37
Jun 18 '10 at 17:58
source share

You can set the Listview property as

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

Here custom_scroll_style is an xml file in a folder with the ability to transfer. Let's create custom_scroll_style.xml.

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <gradient android:angle="45" android:endColor="#FF3401" android:centerColor="#ff5c33" android:startColor="#FF3401" /> <corners android:radius="8dp" /> <size android:width="4dp"/> <padding android:left="0.5dp" android:right="0.5dp" /> </shape> 

Here I got an orange scrollbar. You can also use images if the image size is less than 2px instead of xml.

+76
Dec 24 '13 at 12:47
source share



All Articles