简体   繁体   中英

How can I change the color of the scrollbar in Android?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM