【问题标题】:Android Action Bar: Changing the color of Action ButtonsAndroid 操作栏:更改操作按钮的颜色
【发布时间】:2012-08-23 19:05:46
【问题描述】:

我有一个带有如下所示操作栏的应用:

我希望菜单操作按钮“主页”和“注销”的文本也为白色。如何更改它们的文本颜色?

如果您想查看任何代码,请告诉我。

谢谢!

【问题讨论】:

    标签: android android-actionbar android-4.0-ice-cream-sandwich actionbarsherlock android-theme


    【解决方案1】:

    据我所知,这是一个名为android:actionMenuTextColor 的简单属性。

    要正确使用它,您应该创建自己的样式,如下所示:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <style name="myTheme" parent="@android:style/Theme.Holo.Light">
            <item name="android:actionMenuTextColor">@color/actionBarText</item>
        </style>
    
        <style name="myTheme.ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar">
            <item name="android:titleTextStyle">@style/myTheme.ActionBar.Text</item>
        </style>
    
        <style name="myTheme.ActionBar.Text" parent="@android:style/TextAppearance">
            <item name="android:textColor">@color/actionBarText</item>
        </style>
    
    </resources>
    

    然后将@color/actionBarText 设置为您选择的颜色。您还可以在此处定义其他值,例如背景颜色。

    【讨论】:

    • 感谢您的回复!这改变了文本颜色。您是否知道是否有办法将“Home”和“Logout”之间的小分隔线也设为白色?
    • 以同样的方式将 android:actionBarDivider 属性设置为您想要的任何内容。 =) 如果你觉得有用,别忘了点赞并接受我的回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-16
    • 1970-01-01
    • 2015-09-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多