Android 更改微调器的分隔器颜色

Android 更改微调器的分隔器颜色,android,android-spinner,Android,Android Spinner,因为我的弹出窗口背景是白色的,所以我需要更改微调器分隔器的颜色。我已尝试按以下方式设置微调器的样式,但不起作用: styles.xml <style name="applicationTheme" parent="@android:style/Theme.Holo.Light"> <item name="android:dropDownListViewStyle">@style/SpinnerStyle</item> </style> &

因为我的弹出窗口背景是白色的,所以我需要更改微调器分隔器的颜色。我已尝试按以下方式设置微调器的样式,但不起作用:

styles.xml

<style name="applicationTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:dropDownListViewStyle">@style/SpinnerStyle</item>
</style>

<style name="SpinnerStyle" parent="android:Widget.ListView.DropDown">
    <item name="android:divider">#0193DE</item>
    <item name="android:dividerHeight">1dp</item>
</style>
<Spinner
        android:id="@+id/year"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:background="@drawable/apptheme_spinner_default_holo_dark"
        android:layout_marginLeft="75dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:spinnerMode="dropdown"
        style="@style/SpinnerStyle" 
        android:popupBackground="#FFFFFF" />
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:textColor="@android:color/white" />

@风格/喷丝板风格
#0193DE
1dp
主xml

<style name="applicationTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:dropDownListViewStyle">@style/SpinnerStyle</item>
</style>

<style name="SpinnerStyle" parent="android:Widget.ListView.DropDown">
    <item name="android:divider">#0193DE</item>
    <item name="android:dividerHeight">1dp</item>
</style>
<Spinner
        android:id="@+id/year"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:background="@drawable/apptheme_spinner_default_holo_dark"
        android:layout_marginLeft="75dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:spinnerMode="dropdown"
        style="@style/SpinnerStyle" 
        android:popupBackground="#FFFFFF" />
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:textColor="@android:color/white" />

java

ArrayAdapter<Integer> adapter_year = new ArrayAdapter<Integer>(this, R.drawable.custom_spinner_holidays, year);
    adapter_year.setDropDownViewResource(R.layout.custom_spinner_popup);
ArrayAdapter\u year=新的ArrayAdapter(此,R.drawable.custom\u微调器\u节假日,年份);
适配器\u year.setDropDownViewResource(R.layout.custom\u微调器\u弹出窗口);
自定义微调器\u holidays.xml

<style name="applicationTheme" parent="@android:style/Theme.Holo.Light">
    <item name="android:dropDownListViewStyle">@style/SpinnerStyle</item>
</style>

<style name="SpinnerStyle" parent="android:Widget.ListView.DropDown">
    <item name="android:divider">#0193DE</item>
    <item name="android:dividerHeight">1dp</item>
</style>
<Spinner
        android:id="@+id/year"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="bottom"
        android:background="@drawable/apptheme_spinner_default_holo_dark"
        android:layout_marginLeft="75dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp"
        android:spinnerMode="dropdown"
        style="@style/SpinnerStyle" 
        android:popupBackground="#FFFFFF" />
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:singleLine="true"
    android:textColor="@android:color/white" />

自定义微调器\u弹出窗口

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="?android:attr/spinnerDropDownItemStyle"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:ellipsize="marquee"
    android:singleLine="true"
    android:textColor="#0193DE" />


我能把所有这些都合并成一个吗?

也许最好的办法是做你自己的纺纱机,你可以按照你想要的方式来设计。请看下一篇文章,它对我非常有用


您需要将此主题放入清单文件中,如下所示:

<activity android:name="com.example.activity.Solution"
        android:theme="@style/applicationTheme">
</activity>


我的实际问题是该样式没有应用到微调器上。没有运行时错误。为什么会这样?也许你忘了在你的活动中设置你的风格?我仍在等待一个完美的答案。。好像什么都没用:(有人能帮我吗?我被困在这里了!