且构网

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

如何更改操作栏的溢出菜单(弹出菜单)的背景颜色

更新时间:2023-01-28 09:48:20

将此添加到工具栏元素

app:popupTheme="@style/ThemeOverlay.YourApp"

然后在您的styles.xml中定义弹出菜单样式

Then in your styles.xml define the popup menu style

<style name="ThemeOverlay.YourApp" parent="ThemeOverlay.AppCompat.Light">
    <item name="android:colorBackground">@color/your_background_color</item>
    <item name="android:textColor">@color/your_text_color</item>
</style>

请注意,您无需使用colorBackground,而不必使用background.后者将应用于所有内容(菜单本身和每个菜单项),前者仅应用于弹出菜单.

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

来源:样式appcompat-v7工具栏菜单背景