1

I want to change the background's color of my overflow menu, I'm using AppCompat as Theme. I tried a bunch of combinations without any result.

My styles.xml

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <item name="android:actionOverflowButtonStyle">@style/OverflowMenuButton</item>
    <item name="android:actionBarStyle">@style/AppBaseTheme.MyActionBar</item>
    <item name="android:actionBarTabStyle">@style/MyActionBarTabs</item>
    <item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
    <item name="android:popupMenuStyle">@style/MyPopupMenu</item>
</style>
...
<style name="MyPopupMenu" parent="style/Widget.AppCompat.Light.ActionButton.Overflow">
    <item name="android:popupBackground">#64666666</item>
</style>

For the attribute I tried both with and without the android namespace (android:) I think that I'm not reffering to the correct parent for my PopupMenu but that's what I found so far.

113408
  • 3,364
  • 6
  • 27
  • 54

2 Answers2

0

You can do action bar style in easy way here

Aristo Michael
  • 2,166
  • 3
  • 35
  • 43
0

Here is the styles.xml which worked for me (the Action bar background and some text colors included, but not required):

<resources xmlns:tools="http://schemas.android.com/tools">

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="actionOverflowMenuStyle">@style/AppTheme.OverflowPopupMenu</item>
    <item name="android:actionBarStyle"   tools:ignore="NewApi">@style/AppTheme.ActionBar</item>
    <item name="actionBarStyle">@style/AppTheme.ActionBar</item>
</style>



<style name="AppTheme.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="android:background"  tools:ignore="NewApi">@color/colorPrimary</item>
    <item name="background">@color/colorPrimary</item>
</style>

<style name="AppTheme.OverflowPopupMenu" parent="Widget.AppCompat.PopupMenu.Overflow">
    <!--<item name="android:popupBackground">@color/colorPrimary</item>-->
    <item name="android:popupBackground">@drawable/menu_dropdown_panel</item>
</style>

I had to use a .9 drawable for the background, though, as if I'm using just the color hex resource - I'm getting a fat black border around my overflow menu. It's still there, but now transparent.

halxinate
  • 1,509
  • 15
  • 22
  • How to change the icon of the action menu? I tried this [solution](https://stackoverflow.com/questions/30267758/how-to-change-three-dots-button-on-android-to-other-button) But it is not working – Kavin Raju S Mar 24 '20 at 06:08
  • How can I change the text color of the menu items? – gingerNinja Jun 16 '20 at 18:54