How to change the background color of Action Bar's Option Menu in Android 4.2?

how to change action bar color in android studio
how to change action bar title color in android
android change actionbar color programmatically
how to change toolbar text color in android
change status bar color android xml
actionbar android
change support action bar color
how to change toolbar color in android

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.

public class MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

    getActionBar().setTitle("Sample Menu");

    int titleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
    TextView titleText = (TextView)findViewById(titleId);


public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);
    return true;

protected void setMenuBackground(){                     
    // Log.d(TAG, "Enterting setMenuBackGround");  
    getLayoutInflater().setFactory( new Factory() { 

        public View onCreateView(String name, Context context,
                AttributeSet attrs) {
            if ( name.equalsIgnoreCase( "" ) ) {
                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 xmlns:android="" >

            android:title="@string/item1" />
            android:title="@string/item2" />
            android:title="@string/item3" />
            android:title="@string/item4" />



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

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.

How to set custom ActionBar color / style?, We need to override these parent theme elements to style the action bar. ActionBar with different color background:-- To do this we need to create  Has the title say, i need to change the background color of my action bar. The project have a min sdk of 9, and max sdk of 19. I have create in my res/values folder, an xml file:

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.


    <style name="MyAppActionBarTheme" parent="android:Theme.Holo.Light">
        <item name="android:popupMenuStyle">@style/MyApp.PopupMenu</item>
        <item name="android:actionBarStyle">@style/MyApp.ActionBar</item>

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

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


And, of course, in AndroidManifest.xml:

    ... >

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="" >

        <shape android:shape="rectangle">
            <stroke android:width="2dp" android:color="#FF000000" />
            <solid android:color="#FF2070B0" />                   

    <item android:bottom="2dp">
        <shape android:shape="rectangle">
            <stroke android:width="2dp" android:color="#FF2070B0" />
            <solid android:color="#00000000" />
            <padding android:bottom="2dp" />


Works great at least on Android 4.0+ (API level 14+).

How to change the color of Action Bar in an Android App , In this article, you will learn how to change the colour of the Action Bar in an Android App. There are two ways to change color. By changing styles.xml file:. maybe this is strange but in my case bar.setBackgroundDrawable(new ColorDrawable(Color.BLUE)); change the action bar color to grey. These happens also if put other color, like Color.RED , Color.GREEN and so on

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.

    <!-- 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 name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="background">@color/red</item>
        <item name="titleTextStyle">@style/MyActionBarTitle</item>

    <style name="MyActionBarTitle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/white</item>

    <style name="MyActionBar.MenuTextStyle"
        <item name="android:textColor">@color/red</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">25sp</item>

and this is how it looks--MenuItem background color is skyblue and MenuItem text color is pink with textsize as 25sp:--

Solved: Is there any way to change the text color in Statu, This example demonstrates how to change the background color of the ActionBar of an ActionBarActivityStep 1 − Create a new project in  ActiveOldestVotes. 11. This is all you need to change the color of the action bar: <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">#995544</item></style>. share|improve this answer|follow ||||.

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>

Then reference it in your theme block:

<style name="" parent="@android:style/Theme.Holo">
    <item name="android:actionBarWidgetTheme">@style/PopupWrapper</item>

That's it!

How to Change Action Bar Background Color and Title color , How do I change the color of my status bar text? Choose a Windows color (for a variety of surfaces that you see when you use Windows) that's Light, Dark, or Custom; Personalize the colors of the Start button, taskbar, and action center (this option is only available if you select Dark or Custom as your Windows color) Choose accent colors to contrast with or match your wallpaper and Windows color

My simple trick to change background color and color of the text in Popup Menu / Option Menu

<style name="CustomActionBarTheme"
    <item name="android:popupMenuStyle">@style/MyPopupMenu</item>
    <item name="android:itemTextAppearance">@style/TextAppearance</item>
<!-- Popup Menu Background Color styles -->
<style name="MyPopupMenu" 
    <item name="android:popupBackground">@color/Your_color_for_background</item> 
<!-- Popup Menu Text Color styles -->
<style name="TextAppearance">
    <item name="android:textColor">@color/Your_color_for_text</item>

Android Studio, How do I change the primary color on my Android? Change colors in Custom mode. Select Start > Settings . Select Personalization > Colors . Open Colors setting. Under Choose your color , select Custom . Under Choose your default Windows mode , select Dark . Under Choose your default app mode , select Light or Dark . To manually select an accent

How to change the Android ActionBar background , This tutorial is for changing Action Bar background and title color and text appearance of Duration: 3:11 Posted: May 7, 2018 How to set custom background color to create action bar. In this tutorial we are creating action bar with background color change so it will modified. So here is the complete step by step tutorial for Change Actionbar background color in android programmatically. We are firstly creating action bar object and then using setBackgroundDrawable

Styling the Action Bar, UX/UI Design: Design Messaging App in Adobe XD GET 50% DISCOUNT (​Limited Time): http Duration: 1:25 Posted: Jul 24, 2017 This will change background color as #004D40. Paramjeet. Replied on September 16, 2015. Really Helpful. Thanks. Android remove action bar using AndroidManifest.xml ;

How to change backgroundcolor of actionbar, By default, the background color of the ActionBar in any Android App is black as shown in the example below. I wanted to style the background 

  • Refer this below link…
  • +1, the only way I found to make it work was indeed the Style Generator. If you don't want to add all of the dozens of files it creates to your project, check out this.
  • this doesnt answer the question of how exactly to do this, even though it solves the problem
  • Thanks Jonik. This worked for me to change the Popup background color with android:popupMenuStyle and android:popupBackground. Could you please guide me on the changing the text color in the popup menu?
  • @VikramV: I managed to change the menu text colour using android:itemTextAppearance & android:textColor as described in this answer.
  • For some strange reason this is not working for me on android 4.4. Exact same setup...
  • @artworkadシ, curious; works fine on 4.4 for me. What base theme are you using? If Holo Dark, you could try if this works.
  • GG for the answer, it helped me a lot. Unfortunately i'm using android:Theme.Holo.Light.DarkActionBar and popup won't change. It seems this is a bug :-/ .
  • Thank you @Nicks, android:itemBackground works for me and android:popupBackground not.
  • Yeah, app compatibility is full of trivia that I would have never figured out if not for this site.
  • Thank you for stopping me from going crazy (AppCompat sucks)