8

How can I modify the style of the items on the Action bar of an Android Application?

I tryed the following:

<item name="android:actionBarStyle">@style/ActionBar.Light</item>

<style name="ActionBar.Light" parent="@style/ActionBar">
        <item name="android:background">@color/black</item>
        <item name="android:actionMenuTextColor">#FF00FF</item>
</style>

The background of the Action bar I was able to modify, but not the text Colors of the items in the Action bar. How can I do it?

EDIT:

I tried pretty much all the android:action attributes I found, but I couldn't manage to change anything other than the background. Only the first <item name="android:background">#FF0000</item> of the following code makes changes on my code. No matter which values I put on the Test style, it doesn't change anything. Why is it happening?

<item name="android:actionBarStyle">@style/ActionBar.Light</item>

<style name="ActionBar.Light" parent="@style/ActionBar">
        <item name="android:background">#FF0000</item>
        <item name="android:actionMenuTextColor">@style/Test</item>
        <item name="android:actionButtonStyle">@style/Test</item>
        <item name="android:actionModeBackground">@style/Test</item>
        <item name="android:actionMenuTextAppearance">@style/Test</item>
    </style>

    <style name="Test">
        <item name="android:textColor">@color/white</item>
        <item name="android:background">#FF0000</item>
    </style>
Paulo Barros
  • 2,740
  • 8
  • 28
  • 36

2 Answers2

15

If you want to change the color of the menu items in the action bar you have to set the actionMenuTextColor in your theme style.

<style name="PortfolioTheme" parent="android:style/Theme.Holo.Light">
   <item name="android:actionMenuTextColor">#24598a</item>
   <item name="actionMenuTextColor">#24598a</item>
</style>

You don't define the menu item colors in the actionMenuTextAppearance!

Tooroop
  • 1,824
  • 1
  • 20
  • 31
  • Hello, I tried this solution. It changes the menu items color in action bar. But may sub menu items are not changing. What should i do to change the color or sub menu items. – Dory Apr 24 '13 at 09:28
  • Hi, you are probably talking about changing the overflow menu style. I am not really 100% sure about the solution but try checkign these links: https://groups.google.com/forum/?fromgroups=#!topic/actionbarsherlock/5lHOKNlXn_4 http://stackoverflow.com/questions/14859794/actionbar-styled-overflow-menu-items – Tooroop Apr 25 '13 at 09:31
  • This is the sh*t that did it for me. It also works on the ActionBarCompat (the v7 support package for Android). Having a quick look in the resource files provided for the ActionBarCompat by the support package also confirms the `actionMenuTextColor` attribute. – dbm Dec 17 '13 at 07:17
0

You can change the color by:-

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
</style>

<style name="MyTheme.ActionBarStyle" parent="android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>

<style name="MyTheme.ActionBar.TitleTextStyle" parent="android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">@color/red</item>
</style>
</resources>
user755278
  • 1,634
  • 3
  • 16
  • 32