我无法弄清楚为什么旋转器的文字颜色不会改变颜色。你能帮我解决这个问题。
<style name="Theme.Material_Dark." parent="Theme.AppCompat.Light.NoActionBar">
</style>
<style name="ActionBarThemeOverlay" parent="">
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
<item name="android:spinnerStyle">@style/SpinnerItem.DropDownItem</item>
</style>
<style name="SpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
<item name="android:textColor">@color/actionbar_bg_dk</item>
</style>
<style name="SpinnerItem.DropDownItem" parent="android:TextAppearance.Widget.TextView.SpinnerItem">
<item name="android:textColor">@color/White</item>
<item name="android:popupBackground">#424242</item>
</style>
答案 0 :(得分:2)
创建TextView布局 dropdown_spinner_text.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinner_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textSize="20sp"
android:textColor="@color/colorBlack"
android:background="@color/colorWhite"/>
然后将其设置为您的下拉资源。
spinnerAdapter.setDropDownViewResource(R.layout.dropdown_spinner_text);
答案 1 :(得分:0)
将声明的项目样式添加到textAppearance
<style name="ActionBarThemeOverlay" parent="">
<item name="android:spinnerItemStyle">@style/SpinnerItem</item>
</style>
<style name="SpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
<item name="android:textColor">@color/actionbar_bg_dk</item>
<item name="android:textAppearance">@style/SpinnerItem.DropDownItem"</item>
</style>
<style name="SpinnerItem.DropDownItem" parent="android:TextAppearance.Widget.TextView.SpinnerItem">
<item name="android:textColor">@color/White</item> //drop down item text color
<item name="android:popupBackground">#424242</item>
</style>