如何更改操作栏的溢出菜单(弹出菜单)的背景颜色 [英] How to change background color of overflow menu (popup Menu) for action bar

查看:240
本文介绍了如何更改操作栏的溢出菜单(弹出菜单)的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用android Compact库来为旧版和新版android构建操作栏.所以我的要求包括我需要将操作栏显示为蓝色.现在,我已将操作栏的背景色更改为蓝色,现在我想将弹出菜单的背景色更改为单击溢出图标时出现的菜单.我尝试了很多方法,但是没有改变背景色.有人建议我是否可以使用app-compact库更改弹出菜单的背景色,如果可以的话,请建议我

I am using android compact library for building the action bar for both older and newer versions of android. so my requirement includes that i need to show action bar in blue color. now i have changed the action bar background color to blue , now i want to change the background color of popup menu which comes when we click on overflow icon. I tried in many ways but nothing is changing the background color.any one suggest me whether we can change the background color of popup menu using app-compact library or not, if we can please suggest me

推荐答案

将此添加到工具栏元素

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工具栏菜单背景

这篇关于如何更改操作栏的溢出菜单(弹出菜单)的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆