如何更改选项菜单的背景颜色? [英] How to change the background color of the options menu?

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

问题描述

我正在尝试更改选项菜单的默认颜色,即白色:我希望选项菜单上的每个项目都具有黑色背景.

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.

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

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