【问题标题】:Android Actionbar navigation spinner text colorAndroid Actionbar 导航微调器文本颜色
【发布时间】:2012-09-12 19:56:04
【问题描述】:

我可以更改导航微调器的背景:

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

还有什么想法吗?

【问题讨论】:

    标签: android android-actionbar android-theme


    【解决方案1】:

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

    在主题文件中,可以设置 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>
    

    希望这会有所帮助!

    【讨论】:

    • 找不到与给定名称“Widget”匹配的资源
    • @Mike 如果您使用的是 Sherlok 操作栏,请使用 parent="TextAppearance.Sherlock.Widget.ActionBar.Title",如果没有,应该是类似的。
    • 他忘了在Widget前面加android:
    • 你能详细说明如何使用它吗?那么这个父主题呢?
    • 我的文字颜色没有改变。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-07
    相关资源
    最近更新 更多