Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Action Bar: Changing the color of Action Buttons

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

http://postimage.org/image/ozwy8o4x7/

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!

like image 879
James Harpe Avatar asked Dec 04 '22 14:12

James Harpe


1 Answers

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.

like image 77
Qw4z1 Avatar answered Dec 07 '22 04:12

Qw4z1