如何在android中更改溢出菜单的背景色

如何在android中更改溢出菜单的背景色,android,android-actionbar,overflow,background-color,Android,Android Actionbar,Overflow,Background Color,我想更改溢出弹出菜单的背景颜色,以匹配主屏幕的背景。有人知道我怎么做吗? 谢谢。如果您正在使用工具栏,首先需要将此行添加到工具栏布局中: app:popupTheme="@style/ThemeOverlay.MyTheme" 应该是这样的: <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://sche

我想更改溢出弹出菜单的背景颜色,以匹配主屏幕的背景。有人知道我怎么做吗?

谢谢。

如果您正在使用工具栏,首先需要将此行添加到工具栏布局中:

app:popupTheme="@style/ThemeOverlay.MyTheme"
应该是这样的:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    android:background="@color/primary"
    app:titleTextColor="@color/white"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/ThemeOverlay.MyTheme"/>

您需要使用该行来告诉工具栏要使用哪个主题。然后,将以下主题添加到styles.xml文件中:

<style name="ThemeOverlay.MyTheme" parent="ThemeOverlay.AppCompat.Light">
    <item name="android:colorBackground">@color/primary</item>
    <item name="android:textColor">@color/white</item>
</style>

@颜色/原色
@颜色/白色

在我放置“@color/primary”和“@color/white”的地方,你可以使用任何你想要的颜色,你也可以放置像#000000这样的十六进制值。

我很乐意帮忙!检查材料/appcompat v21解决方案