1

I am following this S.O. post about changing the appearance of the Action overflow menu, and it tells me to create a theme to create the desired changes.

I know how to create a theme, and I know how to apply a theme to the whole application or a specific activity, but I don't understand how to apply a theme specifically to the ActionBar / Action Overflow Menu.

From the accepted answer of the above mentioned S.O. post, I've created this theme. Could someone help me understand how to apply it to the ActionBar / Action Overflow menu?

<style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow" >
    <item name="overlapAnchor">false</item>
    <item name="dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
Community
  • 1
  • 1
Timothy Steele
  • 773
  • 1
  • 7
  • 19

1 Answers1

0

Try to create a whole new theme, overriding only the part you have interest in modifying. Assuming the parent theme of your app is "Theme.AppCompat.Light.DarkActionBar":

    <style name="CustomTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:actionBarStyle">@style/MyActionBar</item>
        <item name="android:actionOverflowMenuStyle">@style/OverflowMenu</item>
    </style>

    <style name="MyActionBar" parent="Widget.AppCompat.ActionBar.Solid">
        <!--Your custom ActionBar items-->
    </style>

   <style name="OverflowMenu" parent="Widget.AppCompat.PopupMenu.Overflow" >
       <item name="overlapAnchor">false</item>
       <item name="dropDownVerticalOffset">?attr/actionBarSize</item> 
   </style>

Then you apply this theme in the Android Manifest to the whole app or to the single activities, adding the line:

android:theme="@style/CustomTheme"
Ruocco
  • 575
  • 2
  • 12
  • 26