3

The current problem is that our theme is inheriting from Theme.AppCompat, which appears to have a white scrollbar, and that is not visible on the white background. I know that I can use

<item name="android:scrollbarThumbVertical">@drawable/scroll_thumb</item>

And create a shape for the custom Scrollbar. But I only want to change it to a darker color. When I use a simple colored rectangle shape, it has a different width than the normal scrollbar.

Is this possible?

Björn Kechel
  • 7,933
  • 3
  • 54
  • 57
  • use android:scrollbarThumbVertical="@drawable/custom_scroll_style" into xml layout rather than in theme style.xml – Kishore Jethava Sep 08 '15 at 09:41
  • thanks, but I want to change the theme, because it is used at many places and I do not want to edit all the layout files. – Björn Kechel Sep 08 '15 at 09:43
  • @bjornson Scrollbar thumb color is set to the `colorAccent` attribute in your app theme. did you set it? – karan Sep 08 '15 at 10:30
  • @Karan Mer, thanks for the info, colorAccent requires Api Level 21, but I need to support all the way back to level 15, any ideas how to set it for the old versions? – Björn Kechel Sep 08 '15 at 11:37
  • I will be offline for the afternoon, so I won't be able to reply for the next few hours. – Björn Kechel Sep 08 '15 at 11:39
  • you just need to use it as `android:colorAccent` for the older versions – karan Sep 08 '15 at 12:10
  • thanks again Karan, but android:colorAccent still needs level 21, do you also know what will change besides the scrollbar, when this value is changed? – Björn Kechel Sep 09 '15 at 07:54

1 Answers1

12

ok, it is possible to use a color for the scrollbarThumbVertical item value, but this will change the width, so I set the size to 4dp, which

seems to be the same as in the other views with the native scrollbars

    <item name="android:scrollbarSize">4dp</item>
    <item name="android:scrollbarThumbVertical">@color/scrollbar_thumb</item>

I don't like having to set the size, but I don't see any other way that would be cleaner.

Björn Kechel
  • 7,933
  • 3
  • 54
  • 57