简体   繁体   English

Android 如何在 Spinner 中更改滚动条颜色

[英]Android How to change scrollbar color in Spinner

How can I change the default color of scrollbar present in the spinner?如何更改微调器中滚动条的默认颜色? is it possible to do it on an app level?是否可以在应用程序级别上做到这一点?

<Spinner
        android:id="@+id/location"
        style="@style/Widget.AppCompat.Spinner.Underlined"
        android:layout_width="0dp"
        android:layout_height="45dp"
        android:backgroundTint="@color/input_borde"/>

You can with android:scrollbarThumbVertical="@drawable/youdrawable你可以用android:scrollbarThumbVertical="@drawable/youdrawable

For example:例如:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <gradient android:startColor="#66C0C0C0" android:endColor="#66C0C0C0"
        android:angle="45"/>
    <corners android:radius="6dp" />

</shape>

Spinners in Android doesn't have a Scrollbar, the scrollbar exists within the listView maintained inside the Spinner, and has no public access. Android 中的 Spinner 没有滚动条,滚动条存在于 Spinner 内部维护的 listView 中,并且没有公共访问权限。

There's a run-time way to override it in the link below在下面的链接中有一种运行时方法可以覆盖它

Resource: URL资源: 网址

Custom spinner: URL自定义微调器: URL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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