1

I want change background of menu and set it to blue. Now background of my menu is black.How to change this? Menu xml file :

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.nabege.AboutUsActivity" > 

<item
    android:id="@+id/help" 
    android:title="@string/help" />
<item
    android:id="@+id/setting"
    android:title="@string/setting"/>

Java codes :

  @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.about_us, menu);
            return super.onCreateOptionsMenu(menu);
        }

enter image description here

hmahdavi
  • 2,250
  • 3
  • 38
  • 90
  • you are using toolbar?? add theme in question – Dhaval Parmar Feb 08 '16 at 05:47
  • Check out this : http://stackoverflow.com/questions/19659637/how-to-change-the-background-color-of-action-bars-option-menu-in-android-4-2 – Haresh Chhelana Feb 08 '16 at 05:51
  • @programmer138200: change theme dark to light – Dhaval Parmar Feb 08 '16 at 05:53
  • Here is tutorial about it: https://www.google.com.np/url?sa=t&rct=j&q=&esrc=s&source=web&cd=14&cad=rja&uact=8&ved=0ahUKEwiOrOStvefKAhWMBY4KHa72AVg4ChAWCCgwAw&url=http%3A%2F%2Fwww.viralandroid.com%2F2016%2F01%2Fhow-to-change-background-and-text-color-of-android-actionbar-option-menu.html&usg=AFQjCNERLPyldALDN8_f54YI_54zgkxOxA&sig2=rkUQ44UbqJzew0ZjY7zdTg&bvm=bv.113370389,d.c2E – Pacific P. Regmi Feb 08 '16 at 05:56

1 Answers1

0

Put the following styles in your styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">@color/primary_color</item>
        <!--<item name="colorPrimaryDark">@color/primary_color</item>-->
        <item name="colorAccent">@color/primary_color</item>
        <item name="actionBarStyle">@style/AppThemeActionBarStyle</item>
</style>

<style name="AppThemeActionBarStyle" parent="@style/Widget.AppCompat.Light.ActionBar">
        <item name="background">@color/your_background_color</item>
</style>

Hope this helps.

Mustansar Saeed
  • 2,730
  • 2
  • 22
  • 46