繁体   English   中英

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

[英]How to change the background color of the overflow menu in android

我想更改溢出弹出菜单的背景颜色以匹配主屏幕的背景。 有谁知道我怎么能这样做?
谢谢。

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

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这样的十六进制值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM