Android微调器颜色

Android微调器颜色,android,android-spinner,android-drawable,Android,Android Spinner,Android Drawable,我正在尝试将微调器的背景色设置为白色。这是我想对微调器进行的唯一更改,但我看到的每个解决方案要么需要制作自定义微调器,要么需要更改样式,要么需要一些其他漫长而过于复杂的过程来更改颜色。有没有一种方法可以很容易地改变颜色。我喜欢创建一个可绘制的图形并将其设置为背景的方法。我在下面找到的解决方案适用于api>=23,但我需要最小值为19的解决方案。有没有一种简单的方法,或者我必须创建一个自定义微调器来更改颜色?这就是我想让它看起来的样子 使用简化版本而不设置宽度/高度要求>=23,如下所示 <

我正在尝试将微调器的背景色设置为白色。这是我想对微调器进行的唯一更改,但我看到的每个解决方案要么需要制作自定义微调器,要么需要更改样式,要么需要一些其他漫长而过于复杂的过程来更改颜色。有没有一种方法可以很容易地改变颜色。我喜欢创建一个可绘制的图形并将其设置为背景的方法。我在下面找到的解决方案适用于api>=23,但我需要最小值为19的解决方案。有没有一种简单的方法,或者我必须创建一个自定义微调器来更改颜色?这就是我想让它看起来的样子

使用简化版本而不设置宽度/高度要求>=23,如下所示

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape>
            <solid android:color="@android:color/white" />
        </shape>
    </item>
    <item>
        <bitmap
            android:gravity="end"
            android:src="@drawable/arrow_dropdown" />
    </item>
</layer-list> 

但它使高度过大,使整个屏幕看起来像关闭。我不知道有什么方法可以改变23岁之前的身高,你可以给它设置一个主题属性

使用自定义名称空间并进行设置

其中,自定义样式在样式目录中定义为:

 <style name="custom_style" parent="Theme.AppCompat">
        <item name="colorControlNormal"><!--this color is not of importance --></item>
        <item name="colorControlActivated">#FFFFFF</item>
    </style>

将白色添加到progressbar颜色。为分级栏工作。假设也适用于progressbars

最后,我使用了第二种方法,只是手动设置微调器的高度。下面是微调器代码最后的样子

<Spinner
      android:layout_width="match_parent"
      android:layout_height="35dp"
      android:background="@drawable/custom_spinner"
      android:id="@+id/type" />
定制旋转器

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape>
            <solid android:color="@android:color/white" />
        </shape>
    </item>
    <item>
        <bitmap
            android:gravity="end"
            android:src="@drawable/arrow_dropdown" />
    </item>
</layer-list>
<Spinner
      android:layout_width="match_parent"
      android:layout_height="35dp"
      android:background="@drawable/custom_spinner"
      android:id="@+id/type" />
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape>
            <solid android:color="@android:color/white" />
        </shape>
    </item>
    <item>
        <bitmap
            android:gravity="end"
            android:src="@drawable/arrow_dropdown" />
    </item>
</layer-list>