在程序中可以改變下拉列表導航的背景顏色:
<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>