I would like custom background & text color for my overflow menu. It works fine with devices without hardware menu button, but I'm not able to style devices with hardware menu button. See the screenshots:
I'm using these styles:
<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar"> <item name="android:popupMenuStyle">@style/settleup_PopupMenu</item> <item name="android:actionMenuTextColor">@android:color/white</item> </style> <style name="settleup_PopupMenu" parent="@style/Widget.Sherlock.ListPopupWindow"> <item name="android:popupBackground">@drawable/menu_dropdown_panel_settleup</item> </style>
The Android overflow menu is accessed from the far right of the actions toolbar at the top of the display of the running app.
The right-hand side of the action bar shows the actions. The action buttons (3) show the most important actions of your app. Actions that do not fit in the action bar are moved to the action overflow, and an overflow icon appears on the right. Tap on the overflow icon to display the list of remaining action views.
The action overflow in the action bar provides access to your app's less frequently used actions. The overflow icon only appears on phones that have no menu hardware keys. Phones with menu keys display the action overflow when the user presses the key. Action overflow is pinned to the right side.
The overflow icon is a common UI convention that's leveraged throughout Android to hide settings and other unimportant options. Google is now replacing it in the Play Store with a “tap & hold” gesture and bottom sheet menu.
I've looked into the problem. And there seems to be no way in changing textColor
for the options menu for Android >= 4.0 devices with HW menu key. Not even changing primary, secondary or tertiary colors affected the text color.
The only "solution" that comes to my mind now is some pretty nasty use of java reflection API.
However, you can set the background of the bottom options menu of Android >= 4.0 HW key devices separately from the background of the non-HW key dropdown menu.
You already has the styling for non-HW key dropdown menu. The non-HW key dropdown menu is defined by android:popupMenuStyle
(and popupMenuStyle
):
<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar"> <item name="android:popupMenuStyle">@style/settleup_PopupMenu</item> </style>
But the background of the Android >= 4.0 HW key bottom options menu is defined with android:panelBackground
item in the theme:
<style name="Theme.settleup" parent="@style/Theme.Sherlock.Light.DarkActionBar"> <item name="android:panelBackground">@drawable/mybackground</item> </style>
Since it seems to be a problem to change the text color for bottom options menu on Android >= 4.0 HW key devices, I would suggest to leave this part to its default styling.
Been digging in the AppCompat theming but whatever I tried the textColor remains white. What I do now is just popup the Toolbar menu manually like this:
@Override public boolean onKeyUp(int keycode, KeyEvent e) { switch (keycode) { case KeyEvent.KEYCODE_MENU: if ( getSupportActionBar() != null ) { getSupportActionBar().openOptionsMenu(); return true; } } return super.onKeyUp(keycode, e); }
Pressing the menu button while the menu is open magically closes it.
Who needs the ugly black bottom aligned menu anyway?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With