当我点击操作栏中的某个项目时,我的popum菜单会显示黑色背景主题颜色。我想改变弹出菜单的主题,使其具有全息光(白色)。
我该怎么做?
这是我的style.xml文件,暂时为空:
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
</resources>
清单摘录:
<application
android:name="com.app.ccccccc.activities.cccccccc"
android:hardwareAccelerated="true"
android:allowBackup="true"
android:icon="@drawable/ic_action_blob"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
答案 0 :(得分:3)
在操作菜单的onClick上,您可以以编程方式编写用于设置背景颜色的代码。
或使用,
<style name="AppTheme" parent="android:Theme.Light">
<item name="android:popupMenuStyle">@style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="@android:style/Widget.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
manifest.xml:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
.............
</application>
答案 1 :(得分:1)
尝试按如下方式编辑styles.xml
:
在您的基本主题中:
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
...
<item name="android:popupMenuStyle">@style/PopupMenuStyle</item>
</style>
然后像这样定义PopupMenuStyle
:
<style name="PopupMenuStyle" parent="android:Widget.Holo.Light.PopupMenu">
<item name="android:popupBackground">@android:color/white</item>
</style>
请注意,默认弹出菜单样式不会将背景设置为纯色,就像我上面所做的那样,而是使用带有9补丁背景的状态列表,以提供阴影等。 / p>