Android Material Design主题选择器颜色

时间:2015-09-21 10:59:10

标签: android picker

我在Android中有一个Material设计主题。我想更改我的选择器标签和按钮颜色,因为它显示为白色(colorPrimary)但我不能这样做。

这是我的主题:

<resources>
    <style name="Theme.Cuponisimo" parent="@style/Theme.AppCompat">
        <item name="colorPrimary">@color/azulCuponisimo</item>
        <item name="colorControlActivated">@color/azulOscuro</item>
        <item name="colorAccent">@color/azulCuponisimo</item>
        <item name="colorControlNormal">#ffffff</item>
        <item name="colorControlHighlight">@color/azulClaro</item>

        <item name="android:statusBarColor">@color/azulCuponisimo</item>
        <item name="android:navigationBarColor">@color/azulCuponisimo</item>
        <item name="android:textColorPrimary">#ffffff</item>

    </style>

    <color name="azulCuponisimo">#0a80b0</color>
    <color name="azulOscuro">#01506e</color>
    <color name="azulClaro">#9dccdf</color>

</resources>

enter image description here

我希望我的选择器具有azulCuponisimo颜色,但总是白色。请帮帮我!

1 个答案:

答案 0 :(得分:0)

最后,我找到了解决方案:

在android-holo-colors中创建ColorSpinner,然后

<强> custom_theme.xml

<item name="android:spinnerStyle">@style/Spinner</item>
<item name="android:spinnerDropDownItemStyle">@style/SpinnerDropDownItem</item>
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>

<强> styles_nameTheme.xml

<style name="Spinner" parent="android:Widget.Spinner">
        <item name="android:background">@drawable/nameTheme_spinner_background_holo_light</item>
        <item name="android:dropDownSelector">@drawable/nameTheme_list_selector_holo_light</item>
    </style>

    <style name="SpinnerDropDownItem" parent="android:Widget.DropDownItem.Spinner">
        <item name="android:checkMark">@drawable/nameTheme_btn_radio_holo_light</item>
        <item name="android:textColor">@color/verdeOscuro</item>
        <item name="android:background">#ffffff</item>
    </style>

    <style name="SpinnerItem" parent="android:Widget.TextView.SpinnerItem">
        <item name="android:textAppearance">@style/AppearanceSpinnerItem</item>
    </style>

    <style name="AppearanceSpinnerItem" parent="android:TextAppearance.Widget.TextView.SpinnerItem">
        <item name="android:textColor">@color/verdeOscuro</item>
    </style>

这很完美。我希望它可以帮到你。