6

我能够更改导航微调器的背景:

  <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>

还有什么想法吗?

4

1 回答 1

13

我一直在寻找相同的答案,但没有找到任何东西,所以我尝试了这个解决方案。我至少为我工作。

在主题文件中,您可以设置 spinnerDropdownItemStyle 的样式:

<style name="YourTheme" parent="YourParentTheme">
    <item name="android:spinnerDropDownItemStyle">@style/YourCustomDropDownItemStyle</item>
</style>

现在,为您的样式设置 textappearance:

<style name="YourCustomDropDownItemStyle" parent="@android:style/Widget.Holo.DropDownItem.Spinner">
    <item name="android:textAppearance">@style/YourCustomDropDownItemTextStyle</item>
</style>

在您的自定义文本外观中,您可以设置文本详细信息:

<style name="YourCustomDropDownItemTextStyle" parent="@android:style/Widget">
    <item name="android:textColor">@color/white</item>
    <!-- Here you can set the color and other text attributes -->
</style>

希望这可以帮助!

于 2012-09-19T20:54:51.787 回答