I'd like to change the background color of the option (overflow) menu in Android 4.2. I have tried all the methods but it is still showing the default color set by the theme. I used the following code & XML configs.
MainActivity.java
public class MainActivity extends Activity {
#SuppressLint("NewApi")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getActionBar().setIcon(R.drawable.ic_launcher);
getActionBar().setTitle("Sample Menu");
getActionBar().setBackgroundDrawable(new
ColorDrawable(Color.parseColor("#33B5E5")));
int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
TextView titleText = (TextView)findViewById(titleId);
titleText.setTextColor(Color.parseColor("#ffffff"));
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
setMenuBackground();
return true;
}
protected void setMenuBackground(){
// Log.d(TAG, "Enterting setMenuBackGround");
getLayoutInflater().setFactory( new Factory() {
#Override
public View onCreateView(String name, Context context,
AttributeSet attrs) {
if ( name.equalsIgnoreCase( "com.android.internal.view.menu.IconMenuItemView" ) ) {
try { // Ask our inflater to create the view
LayoutInflater f = getLayoutInflater();
final View view = f.createView( name, null, attrs );
/* The background gets refreshed each time a new item is added the options menu.
* So each time Android applies the default background we need to set our own
* background. This is done using a thread giving the background change as runnable
* object */
new Handler().post( new Runnable() {
public void run () {
// sets the background color
view.setBackgroundResource( R.color.menubg);
// sets the text color
((TextView) view).setTextColor(Color.WHITE);
// sets the text size
((TextView) view).setTextSize(18);
}
} );
return view;
}
catch ( InflateException e ) {}
catch ( ClassNotFoundException e ) {}
}
return null;
}});
}
}
Menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="#+id/action_settings"
android:icon="#drawable/menu"
android:showAsAction="always"
android:title="#string/action_settings">
<menu>
<item
android:id="#+id/item1"
android:showAsAction="always"
android:title="#string/item1" />
<item
android:id="#+id/item2"
android:showAsAction="always"
android:title="#string/item2" />
<item
android:id="#+id/item3"
android:showAsAction="always"
android:title="#string/item3" />
<item
android:id="#+id/item4"
android:showAsAction="always"
android:title="#string/item4" />
</menu>
</item>
</menu>
color.xml
<color name="menubg">#33B5E5</color>
The above setMenuBackground is not taking any effect:
In the above picture, I want to change the menu background from black to the blue color in the Action Bar. How can I achieve this, and what I did do wrong?
In case people are still visiting for a working solution, here is what worked for me:-- This is for Appcompat support library.
This is in continuation to ActionBar styling explained here
Following is the styles.xml file.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<!-- This is the styling for action bar -->
<item name="actionBarStyle">#style/MyActionBar</item>
<!--To change the text styling of options menu items</item>-->
<item name="android:itemTextAppearance">#style/MyActionBar.MenuTextStyle</item>
<!--To change the background of options menu-->
<item name="android:itemBackground">#color/skyBlue</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#color/red</item>
<item name="titleTextStyle">#style/MyActionBarTitle</item>
</style>
<style name="MyActionBarTitle" parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
<style name="MyActionBar.MenuTextStyle"
parent="style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">25sp</item>
</style>
</resources>
and this is how it looks--MenuItem background color is skyblue and MenuItem text color is pink with textsize as 25sp:--
The Action Bar Style Generator, suggested by Sunny, is very useful, but it generates a lot of files, most of which are irrelevant if you only want to change the background colour.
So, I dug deeper into the zip it generates, and tried to narrow down what are the parts that matter, so I can make the minimum amount of changes to my app. Below is what I found out.
In the style generator, the relevant setting is Popup color, which affects "Overflow menu, submenu and spinner panel background".
Go on and generate the zip, but out of all the files generated, you only really need one image, menu_dropdown_panel_example.9.png, which looks something like this:
So, add the different resolution versions of it to res/drawable-*. (And perhaps rename them to menu_dropdown_panel.9.png.)
Then, as an example, in res/values/themes.xml you would have the following, with android:popupMenuStyle and android:popupBackground being the key settings.
<resources>
<style name="MyAppActionBarTheme" parent="android:Theme.Holo.Light">
<item name="android:popupMenuStyle">#style/MyApp.PopupMenu</item>
<item name="android:actionBarStyle">#style/MyApp.ActionBar</item>
</style>
<!-- The beef: background color for Action Bar overflow menu -->
<style name="MyApp.PopupMenu" parent="android:Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_dropdown_panel</item>
</style>
<!-- Bonus: if you want to style whole Action Bar, not just the menu -->
<style name="MyApp.ActionBar" parent="android:Widget.Holo.Light.ActionBar.Solid">
<!-- Blue background color & black bottom border -->
<item name="android:background">#drawable/blue_action_bar_background</item>
</style>
</resources>
And, of course, in AndroidManifest.xml:
<application
android:theme="#style/MyAppActionBarTheme"
... >
What you get with this setup:
Note that I'm using Theme.Holo.Light as the base theme. If you use Theme.Holo (Holo Dark), there's an additional step needed as this answer describes!
Also, if you (like me) wanted to style the whole Action Bar, not just the menu, put something like this in res/drawable/blue_action_bar_background.xml:
<!-- Bonus: if you want to style whole Action Bar, not just the menu -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle">
<stroke android:width="2dp" android:color="#FF000000" />
<solid android:color="#FF2070B0" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle">
<stroke android:width="2dp" android:color="#FF2070B0" />
<solid android:color="#00000000" />
<padding android:bottom="2dp" />
</shape>
</item>
</layer-list>
Works great at least on Android 4.0+ (API level 14+).
There is an easy way to change the colors in Actionbar
Use ActionBar Generator and copy paste all file in your res folder and change your theme in Android.manifest file.
If you read this, it's probably because all the previous answers didn't work for your Holo Dark based theme.
Holo Dark uses an additional wrapper for the PopupMenus, so after doing what Jonik suggested you have to add the following style to your 'xml' file:
<style name="PopupWrapper" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/YourPopupMenu</item>
</style>
Then reference it in your theme block:
<style name="Your.cool.Theme" parent="#android:style/Theme.Holo">
.
.
.
<item name="android:actionBarWidgetTheme">#style/PopupWrapper</item>
</style>
That's it!
My simple trick to change background color and color of the text in Popup Menu / Option Menu
<style name="CustomActionBarTheme"
parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/MyPopupMenu</item>
<item name="android:itemTextAppearance">#style/TextAppearance</item>
</style>
<!-- Popup Menu Background Color styles -->
<style name="MyPopupMenu"
parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#color/Your_color_for_background</item>
</style>
<!-- Popup Menu Text Color styles -->
<style name="TextAppearance">
<item name="android:textColor">#color/Your_color_for_text</item>
</style>
Within your app theme you can set the android:itemBackground property to change the color of the action menu.
For example:
<style name="AppThemeDark" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/drk_colorPrimary</item>
<item name="colorPrimaryDark">#color/drk_colorPrimaryDark</item>
<item name="colorAccent">#color/drk_colorAccent</item>
<item name="actionBarStyle">#style/NoTitle</item>
<item name="windowNoTitle">true</item>
<item name="android:textColor">#color/white</item>
<!-- THIS IS WHERE YOU CHANGE THE COLOR -->
<item name="android:itemBackground">#color/drk_colorPrimary</item>
</style>
I'm also struck with this same problem, finally i got simple solution. just added one line to action bar style.
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="android:textColorPrimary">#color/colorAccent</item>
<item name="android:colorBackground">#color/colorAppWhite</item>
</style>
"android:colorBackground" is enough to change option menu background
FAST way!
styles.xml
<style name="popupTheme" parent="Theme.AppCompat.Light">
<item name="android:background">#color/colorBackground</item>
<item name="android:textColor">#color/colorItem</item>
</style>
Then add this specific styles to your AppTheme styles
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="popupTheme">#style/popupTheme</item>
</style>
DONE!
You can apply styles and Themes in Overflow MenuItem as per below. OverFlow Menu is ListView so, we can apply theme as per listview.
Apply below code in styles.xml
<style name="AppTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:dropDownListViewStyle">#style/PopupMenuListView</item>
<item name="android:actionBarWidgetTheme">#style/PopupMenuTextView</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
<item name="android:listPreferredItemHeightSmall">40dp</item>
</style>
<!-- Change Overflow Menu ListView Divider Property -->
<style name="PopupMenuListView" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:divider">#color/app_navigation_divider</item>
<item name="android:dividerHeight">1sp</item>
<item name="android:listSelector">#drawable/list_selector</item>
</style>
<!-- Change Overflow Menu ListView Text Size and Text Size -->
<style name="PopupMenuTextView" parent="#android:style/Widget.Holo.Light.TextView">
<item name="android:textColor">#color/app_white</item>
<item name="android:textStyle">normal</item>
<item name="android:textSize">18sp</item>
<item name="android:drawablePadding">25dp</item>
<item name="android:drawableRight">#drawable/navigation_arrow_selector</item>
</style>
<!-- Change Overflow Menu Background -->
<style name="PopupMenu" parent="android:Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">#drawable/menu_overflow_bg</item>
</style>
I was able to change colour of action overflow by just putting hex value at:
<!-- The beef: background color for Action Bar overflow menu -->
<style name="MyApp.PopupMenu" parent="android:Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">HEX VALUE OF COLOR</item>
</style>
Add following to your Styles.xml
<style name="Custom_Theme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:itemBackground">#color/white</item>
<item name="android:textColor">#color/colorPrimaryDark</item>
</style>
Change theme in activity_main.xml only.
android:theme="#style/Custom_Theme"
Try this code. Add this snippet to your res>values>styles.xml
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarWidgetTheme">#style/Theme.stylingactionbar.widget</item>
</style>
<style name="PopupMenu" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#color/DarkSlateBlue</item>
<!-- for #color you have to create a color.xml in res > values -->
</style>
<style name="Theme.stylingactionbar.widget" parent="#android:style/Theme.Holo">
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
And in Manifest.xml add below snippet under application
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<style name="customTheme" parent="any_parent_theme">
<item name="android:itemBackground">#424242</item>
<item name="android:itemTextAppearance">#style/TextAppearance</item>
</style>
<style name="TextAppearance">
<item name="android:textColor">#E9E2BF</item>
</style>
Following are the changes required in your theme for changing action bar & overflow menu background color. You need to configure "android:background" of actionBarStyle & popupMenuStyle
<application
android:name="...."
android:theme="#style/AppLightTheme">
<style name="AppLightTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/ActionBarLight</item>
<item name="android:popupMenuStyle">#style/ListPopupWindowLight</item>
</style>
<style name="ActionBarLight" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/white</item>
</style>
<style name="ListPopupWindowLight"parent="#android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:background">#color/white</item>
</style>
I used this and it works just fine.
Apply this code in the onCreate() function
val actionBar: android.support.v7.app.ActionBar? = supportActionBar
actionBar?.setBackgroundDrawable(ColorDrawable(Color.parseColor("Your color code here")))
To alter the color of the app bar only, you just have to change the colorPrimary value inside the colors.xml file and the colorPrimaryDark if you want to change the battery bar color as well:
<resources>
<color name="colorPrimary">#B90C0C</color>
<color name="colorPrimaryDark">#B90C0C</color>
<color name="colorAccent">#D81B60</color>
</resources>
How can I change the default logo icon of an ActionBar to be a custom image? Similar as how it works on Whatsapp?
The ActionBar uses the android:logo attribute of your manifest, if one is provided. That lets you use separate drawable resources for the icon (Launcher) and the logo (ActionBar, among other things).
So you should add this tag into manifest like ..
<application
android:logo="#drawable/custom_image"
Update :
You can use ActionBar.setLogo() for runtime. Two versions are there setLogo(int resId) and setLogo(Drawable logo).
Read Define custom Logo for ActionBar (different than Logo) in XML? which will help you to define some styles also.
The simplest technique is to use setIcon(R.drawable.icon_name) Similarly you can do with the Title and you can also set the date in the action bar subtitle.
ActionBar ab= getActionBar();
ab.setTitle("Aries");
ab.setSubtitle(dateFormat.format(date));
ab.setIcon(R.drawable.aries3d);
You need to customize the ActionBarSherlock. Include an xml called "styles_mytheme.xml" in values folder:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Styled" parent="#style/Theme.Sherlock.Light">
<item name="actionBarStyle">#style/CustomActionBarStyle</item>
<item name="android:actionBarStyle">#style/CustomActionBarStyle</item>
<item name="android:actionBarItemBackground">#drawable/overflow_selector</item>
<item name="android:itemBackground">#drawable/overflow_selector</item>
<item name="android:actionBarWidgetTheme">#style/CustomActionOverflowDropDownText</item>
<item name="actionBarWidgetTheme">#style/CustomTitleColorBar</item>
<item name="android:icon">#drawable/ic_nav_home_back</item>
<item name="android:homeAsUpIndicator">#drawable/ic_nav_back</item>
<item name="icon">#drawable/ic_nav_home_back</item>
<item name="dropDownListViewStyle">#style/DropDownStyles</item>
<item name="android:dropDownListViewStyle">#style/DropDownStyles</item>
</style>
<style name="CustomActionBarStyle" parent="#style/Widget.Sherlock.ActionBar">
<!-- define background for action bar (sets default for all parts of action bar - main, stacked, split) -->
<item name="android:background">#drawable/navigation</item>
<item name="background">#drawable/navigation</item>
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<!-- Style for the color title bar -->
<style name="CustomTitleColorBar" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">12sp</item>
</style>
<style name="CustomActionOverflowDropDownText" parent="Widget">
<item name="android:textColor">#color/white</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="#style/TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
<style name="My_Theme" parent="Theme.Sherlock">
<item name="android:popupMenuStyle">#style/MyApp.PopupMenuStyle</item>
<item name="popupMenuStyle">#style/MyApp.PopupMenuStyle</item>
</style>
<style name="MyApp.PopupMenuStyle" parent="Widget.Sherlock.ListPopupWindow">
<item name="android:popupBackground">#drawable/navigation</item>
</style>
<style name="DropDownStyles" parent="Widget.Sherlock.ListView.DropDown">
<item name="android:divider">#null</item>
<item name="android:listSelector">#drawable/overflow_selector</item>
</style>
</resources>
Now include this xml in the code:
setTheme(Theme.Styled);
Now change these three lines, when you change these three lines, the icon will change:
<item name="android:icon">#drawable/ic_nav_home_back</item>
<item name="android:homeAsUpIndicator">#drawable/ic_nav_back</item>
<item name="icon">#drawable/ic_nav_home_back</item>
if(getSupportActionBar() != null) {
getSupportActionBar().setDisplayUseLogoEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.add_contact);
}
I am trying to change the drop down background of the sherlock action bar as well as its text color. Here's what I have tried:
<style name="DropDown" parent="Widget.Sherlock.Spinner.DropDown.ActionBar">
<item name="android:popupBackground">#EDEDED</item>
</style>
<style name="TextAppearance" parent="TextAppearance.Sherlock.Widget.TextView.SpinnerItem">
<item name="android:textColor">#A9A9A9</item>
</style>
<style name="SpinnerItemStyle" parent="Widget.Sherlock.TextView.SpinnerItem">
<item name="android:textAppearance">#style/TextAppearance</item>
</style>
<style name="MyTheme" parent="#style/devcheckStyle">
<item name="android:actionDropDownStyle">#style/DropDown</item>
<item name="actionDropDownStyle">#style/DropDown</item>
<item name="spinnerItemStyle">#style/SpinnerItemStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItemStyle</item>
</style>
The main theme being MyTheme, with the following code I am getting the desirable background color, but I am getting nowhere with the text's color inside the drop down navigation. Can someone please help.
Put that code
<item name="android:textColor">#ffffffff</item>
into your MyTheme code should be like:
<style name="MyTheme" parent="#style/devcheckStyle">
<item name="android:actionDropDownStyle">#style/DropDown</item>
<item name="actionDropDownStyle">#style/DropDown</item>
<item name="spinnerItemStyle">#style/SpinnerItemStyle</item>
<item name="android:spinnerItemStyle">#style/SpinnerItemStyle</item>
</style>
I cannot figure out how to change the action bar items "onPressed" color on Android. I'm not talking about the action bar background color but about the blue over state. How can I change the color of this or at least get rid of it? For instance the App Icon with the homeAsUpIndicator.
I tried to change the action bar style and also the menu item style but nothing worked.
Thanks
EDIT
Here is my implementation so far:
My style xml:
<style name="Theme.AppTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:selectableItemBackground">#android:color/transparent</item>
<item name="android:windowEnterAnimation">#anim/fadein</item>
<item name="android:windowExitAnimation">#anim/fadeout</item>
<item name="android:actionBarItemBackground">#android:color/transparent</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/actionbarheader</item>
<item name="android:backgroundStacked">#drawable/actionbarheader</item>
<item name="android:backgroundSplit">#drawable/actionbarheader</item>
<item name="android:titleTextStyle">#style/ActionBarTitle</item>
<item name="android:actionBarItemBackground">#android:color/transparent</item>
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
<item name="android:homeAsUpIndicator">#drawable/actionbarlogo</item>
<item name="android:icon">#drawable/app_icon</item>>
</style>
<style name="ActionBarTitle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textSize">20sp</item>
</style>
<style name="MyActionButtonStyle" parent="#android:style/Widget.Holo.Light.ActionButton">
<item name="android:background">#android:color/transparent</item>
</style>
Then I have a drawable for the actionbarogo:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/actionbarlogo_on" android:state_pressed="true"/>
<item android:drawable="#drawable/actionbarlogo_on" android:state_focused="true"/>
<item android:drawable="#drawable/actionbarlogo_off"/>
</selector>
My menu xml for the action bar items:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#+id/ContactsMode"
android:icon="#drawable/actionbarcontacts"
android:title="#string/contacts"
android:orderInCategory="100"
android:showAsAction="always"
android:background="#android:color/transparent" />
</menu>
and finally, the item's drawable:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/actionbarcontacts_on" android:state_pressed="true"/>
<item android:drawable="#drawable/actionbarcontacts_on" android:state_focused="true"/>
<item android:drawable="#drawable/actionbarcontacts_off"/>
</selector>
Here is how I create the Menu Items for the ActionBar:
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
actionBar.setIcon(R.drawable.actionbarlogo);
return true;
}
public boolean onPrepareOptionsMenu(Menu menu) {
MenuItem item= menu.findItem(R.id.ContactsMode);
if(ContactsButton)
item.setVisible(true);
else
item.setVisible(false);
return true;
}
To set the background for app icon together with the homeAsUpIndicator (there is a common background for these two icons) you have to set android:actionBarItemBackground item in the theme. The theme has to contain something like this (I assume that you use ActionBarSherlock):
<style name="MyTheme" parent="#style/Theme.Sherlock">
<!-- for ActionBarSherlock -->
<item name="actionBarItemBackground">#drawable/my_background</item>
<!-- for native ActionBar -->
<item name="android:actionBarItemBackground">#drawable/my_background</item>
</style>
Where the drawable drawable/my_background.xml would be a StaleListDrawable, containing something like this:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:drawable="#drawable/my_background_pressed" />
<item
android:drawable="#drawable/my_background_normal" />
</selector>
To disable the background completely, you can set a transparent background, or value #null in the theme might also work.
The theme item android:actionBarItemBackground sets the background for app icon and homeAsUpIndicator. But it also sets the default background for menu items, overflow icon and background for title. These backgrounds can be overridden.
Menu items
To change the menu item background set a proper (android:)actionButtonStyle in the theme like this:
<style name="MyTheme" parent="#style/Theme.Sherlock">
<item name="actionButtonStyle">#style/MyActionButtonStyle</item>
<item name="android:actionButtonStyle">#style/MyActionButtonStyle</item>
</style>
And MyActionButtonStyle will contain something like this:
<style name="MyActionButtonStyle" parent="#style/Widget.Sherlock.ActionButton">
<item name="android:background">#drawable/my_background</item>
</style>
Overflow icon
And finally, to change the overflow icon background set a properandroid:actionOverflowButtonStyle in the theme like this:
<style name="MyTheme" parent="#style/Theme.Sherlock">
<item name="actionOverflowButtonStyle">#style/MyOverflowButtonStyle</item>
<item name="android:actionOverflowButtonStyle">#style/MyOverflowButtonStyle</item>
</style>
And MyOverflowButtonStyle will contain something like this:
<style name="MyOverflowButtonStyle" parent="#style/Widget.Sherlock.ActionButton.Overflow">
<item name="android:background">#drawable/my_background</item>
</style>
Fixed it. There was a parent activity changing the theme in the onCreate method...
I didn't know that you could set the theme programmatically within the activity with:
setTheme(R.style.MyTheme);
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>
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!
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>