且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何更改选项菜单的背景颜色?

更新时间:2023-01-26 19:32:08

在花费了大量时间尝试所有选项之后,我唯一能够使用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.