How to change the menu style on Android 4.x devices using the menu button?

I found that I changed the overflow style of the action bar in my application when I do a selector color change from blue to orange.

Some Android 4.x devices still have a menu button, when I click on it, this list of options does not jump out of the taskbar overflow, but from the bottom of the screen. For such a situation, the list of options will not change according to my style (selector color: orange).

How to change the style for such a menu list?

+4
source share
1 answer

Have you tried the code below?

private void getOverflowMenu() { try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if(menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception e) { e.printStackTrace(); } } 

Call this method at the application level, it might work for you.

0
source

Source: https://habr.com/ru/post/1441717/


All Articles