Monday, 15 August 2011

android - Toolbar options menu background color -


I am using Toolbar for Android. I just want to change the background color of the overflow menu But this is not changing.

Style xml

  & lt; Style name = "MyDarkToolbarStyle" parent = "Widget.AppCompat.Toolbar" & gt; & Lt; Item name = "popuptheme" & gt; @ Style / popup menu menu & lt; / Item & gt; & Lt; Item name = "theme" & gt; @ Style / theme overlay. AppCompat.Dark.ActionBar & lt; / Item & gt; & Lt; / Style & gt; & Lt; Style name = "popupmenuastile" parent = "Android: widget.holo.lite.pop ammenu" & gt; & Lt; Item Name = "Android: Popup Background" & gt; @Android: color / white & lt; / Item & gt; & Lt; / Style & gt;  

Toolbar XML

  & lt; Android.support.v7.widget.ToolbarAndroid: id = "@ + id / tool_bar" Android: layout_width = "Match_parent" android: layout_height = "wrap_content" android: background = "@color / colorprrimary" Android: elevation = "2dp "Android: Theme =" @ Style / MyCardToolbar Style "/> To change the Toolbar Options menu color, add it to your Toolbar element  

>

  App: popupTheme = "@ style / MyDarkToolbarStyle"  

Then define popup menu style in your styles.xml

  & lt; Style name = "MyDarkToolbarStyle" parent = "Theme overlay. AppCompat.Light" & gt; & Lt; Item name = "Android: Color background" & gt; @color/mtrl_white_100 & lt; / Item & gt; & Lt; Item name = "Android: Text collar" & gt; @color/mtrl_light_blue_900 & lt; / Item & gt; & Lt; / Style & gt;  

Note that you need to use the colorBackground not background . The latter will be applied on everything (menu itself and each menu item), applies only on the former popup menu.


No comments:

Post a Comment