【问题标题】:How to change the background color of the overflow menu in android如何在android中更改溢出菜单的背景颜色
【发布时间】:2017-08-26 18:10:24
【问题描述】:

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

【问题讨论】:

    标签: android android-actionbar overflow background-color


    【解决方案1】:

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

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

    【讨论】:

    猜你喜欢
    • 2019-02-25
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    • 2016-03-16
    • 1970-01-01
    相关资源
    最近更新 更多