6

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.

Ronak Manglani
  • 191
  • 2
  • 10
  • 3
    Scrollbar thumb color is set to the `colorAccent` attribute in your theme, I believe. You are sure that is set and is correct, right? – xip Jun 01 '15 at 15:32
  • That did the trick. Wow, I didn't even know there was a thing called accent color. I thought it was only PrimaryColor and PrimaryColorDark. I'm new at this. Thanks for your help.. :) – Ronak Manglani Jun 01 '15 at 17:15
  • hey how to implement this in list view? –  Oct 23 '16 at 05:53

3 Answers3

5

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.

xip
  • 2,475
  • 3
  • 18
  • 24
1

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!

Ajay P. Prajapati
  • 1,973
  • 1
  • 17
  • 34
  • Tried that.. It's still the same. No effect.. :( – Ronak Manglani Jun 01 '15 at 15:19
  • 1
    this works 100% tested by me... anyway.. look in your project... there would be something that changing it... there will be some .xml layout file that rendering that thing.you just need to find it and change it. – Ajay P. Prajapati Jun 01 '15 at 15:24
  • 1
    It worked. It was my mistake, I hadn't set the accent color.. Thanks for your help! – Ronak Manglani Jun 01 '15 at 17:18
  • is there a way to set android:scrollbarThumbVertical="@drawable/custom_scroll_style" from the java side/programmatically? I have a custom listView and on Focus I would like it to change color of the scrollbar. – feltspar Apr 27 '18 at 22:21
0

android:scrollbarThumbVertical will work fine. But if fastscroll is enabled in listView you should define android:fastScrollThumbDrawable in AppTheme or any theme and use it for the activity (in AndroidManifest) which contains listview with fastscroll enabled.

Part of styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:fastScrollThumbDrawable">@drawable/fast_scrollbar_vertical</item>
</style>

part of manifest

    <activity
        android:name=".ListActivity"
        android:label="@string/title_activity_list"
        android:theme="@style/AppTheme" />

and scrollbar drawable should be gradient

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

<gradient
    android:angle="45"
    android:endColor="@color/scroll_color"
    android:centerColor="@color/scroll_color"
    android:startColor="@color/scroll_color" />

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

</shape>
Slashbin
  • 668
  • 5
  • 15