微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android操作栏导航微调器文本颜色

我可以更改导航微调器的背景:
<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>

还有其他想法吗?

解决方法

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

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

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

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

希望这可以帮助!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐