Android Actionbar 导航微调器文本颜色 [英] Android Actionbar navigation spinner text color

查看:27
本文介绍了Android Actionbar 导航微调器文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am able to change the background of the navigation spinner:

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

Nevertheless the textColor is not changed. I also tried other ways to change the 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>

还有其他想法吗?

推荐答案

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

I was looking for the same answer but didn't find anything, so I tried this solution. I works for me at least.

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

In the themes file, you can set the style for the spinnerDropdownItemStyle:

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

现在,为您的样式设置文本外观:

Now, set the textappearance for your style:

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

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

And in your custom textappearance you can set the text details:

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

希望这有帮助!

这篇关于Android Actionbar 导航微调器文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆