Android Action Bar: Changing the color of Action Buttons

旧街凉风 提交于 2019-12-05 01:07:10

问题


I have an app with an action bar that looks like this:

I would like the text of the menu action buttons "Home" and "Logout" to be white as well. How can I change their text color?

Let me know if you want to see any code.

Thanks!


回答1:


As i perceive it this is a simple attribute called android:actionMenuTextColor.

To use it properly you should create your own styles, like this:

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

And then set @color/actionBarText to the color of your choice. You can also define other values here like for instance background color.



来源:https://stackoverflow.com/questions/12098404/android-action-bar-changing-the-color-of-action-buttons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!