是否可以在 ScrollView 或 ListView 中更改滚动条的颜色或外观?
最佳答案
您可以将 Listview 属性设置为
android:scrollbarSize="10dp"
android:scrollbarThumbVertical="@drawable/custom_scroll_style"
这里的custom_scroll_style是drawable文件夹下的一个xml文件。让我们创建 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>
这里我有一个橙色滚动条。如果图像大小小于 2px,您也可以使用图像而不是 xml。
关于android - 在Android中更改滚动条颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3071068/