Given :

ActionBar is made using the Toolbar from AppCompat.

Problem :

SubMenu is shown with a transparent background. A menu of the first level work as it should.

Suspicions :

1) Something is wrong with the styles (they are below).

2) ToolBar and / or AppCompat (v21) jamb anyway.

3) <crossed out> android does not work !!! 11 <\ crossed out> the questioner didn’t fully straighten his arms.


In the styles of this:

<style name="ThemeLight" parent="Theme.AppCompat.Light.NoActionBar"> <item name="popupMenuStyle"> @style /OdnakoPopupMenuLight</item> <item name="dropDownListViewStyle"> @style /OdnakoDropDownListViewLight</item> </style> <style name="OdnakoPopupMenuLight" parent=" @style /Widget.AppCompat.PopupMenu"> <item name="android:popupBackground"> @color /material_grey_400</item> <item name="android:background"> @color /material_grey_400</item> <item name="actionMenuTextColor"> @color /material_grey_800</item> </style> <style name="OdnakoDropDownListViewLight" parent=" @style /Widget.AppCompat.ListView.DropDown"> <item name="android:listSelector">@drawable/selectable_background</item> <item name="android:popupBackground"> @color /material_grey_400</item> <item name="android:background"> @color /material_grey_400</item> <item name="actionMenuTextColor"> @color /material_grey_800</item> </style> 

In these Google you are advised to change the ListView style, but it does not help.

Total :

Google is powerless , I am powerless . Help

  • Eh ... So half of my questions will soon be without a single answer ( Do you really have to change two submenu buttons to one top level? = ( - Yuriy SPb

1 answer 1

As a result, the whole thing was in the absence of one attribute in the style, namely:

 <item name="android:itemBackground">@drawable/selectable_background_light</item> 

For some reason, without it, in some cases, the background of the context menu elements became transparent, although the other properties of the selector worked. Those. when selected, focused, lost and pressed, the color changed, and by default it was transparent.