如何更改选项菜单的背景颜色?
问题描述:
我正在尝试更改选项菜单的默认颜色,即白色:我希望选项菜单上的每个项目都具有黑色背景.
I'm trying to change the default color for the options menu which is white: I want a black background for every item on the options menu.
我已经尝试过在菜单元素内的item元素上进行类似android:itemBackground =#000000"之类的拍摄,但这没用.
I've tried some shoots like android:itemBackground="#000000" on the item element within the menu element but it didn't work.
我该怎么做?
答
在花费了大量时间尝试所有选项之后,我唯一能够使用AppCompat v7来更改溢出菜单背景的应用的方法是使用itemBackground属性:
After spending a considerable amount of time trying all the options, the only way I was able to get an app using AppCompat v7 to change the overflow menu background was using the itemBackground attribute:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
...
<item name="android:itemBackground">@color/overflow_background</item>
...
</style>
从API 4.2到5.0进行了测试.
Tested from API 4.2 to 5.0.