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

别说谁变了你拦得住时间么 提交于 2020-01-03 01:20:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/32454126/how-can-i-change-the-color-of-the-scrollbar-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!