在程序中可以改变下拉列表导航的背景颜色:
<style name="MyTheme" parent="android:style/Theme.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
</style>
<style name="MyDropDownNav" parent="android:style/Widget.Spinner">
<item name="android:background">@drawable/spinner_white</item>
<item name="android:textColor">@color/red</item>
</style>
然而textColor没有变,我又使用别的方法改变 textColor:
<style name="MyActionBar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">?color_actionbar</item>
<item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>
</style>
<style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
<item name="android:textColor">@color/violet</item>
</style>
大家有什么意见呢?
在主文件中,给spinnerDropdownItemStyle设置样式
<style name="YourTheme" parent="YourParentTheme">
<item name="android:spinnerDropDownItemStyle">@style/YourCustomDropDownItemStyle</item>
</style>
为 textappearance 设置样式
<style name="YourCustomDropDownItemStyle" parent="Widget.Holo.DropDownItem.Spinner">
<item name="android:textAppearance">@style/YourCustomDropDownItemTextStyle</item>
</style>
在自定义的 textappearance,设置文本细节:
<style name="YourCustomDropDownItemTextStyle" parent="Widget">
<item name="android:textColor">@color/white</item>
<!-- Here you can set the color and other text attributes -->
</style>
style和theme都是并非运行时能够更改的参数,直接设置background和textColor吧