gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:28:36 25 4
gpt4 key购买 nike

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

最佳答案

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

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

关于android - 如何更改android中溢出菜单的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43158160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com