如何设置actionBar弹出背景?

How to set actionBar popup background?

我正在尝试更改 android.support.v7.widget.toolbar

中的弹出窗口背景

正在尝试这个,但没有帮助:

<style name="DonorUaTheme.ActionBar.Solid" parent="Widget.AppCompat.Toolbar">
        <item name="android:background">@color/material_drawer_primary</item>
        <item name="android:displayOptions">showTitle|showHome</item>
        <item name="android:popupBackground">@color/material_drawer_primary</item>
    </style>

我正在使用 android v15,所以我不能只设置 <item name="android:popupTheme">,但我仍然需要更改弹出背景。

很乐意提供任何帮助

在 styles.xml 文件中尝试此代码

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primary</item>

</style>

您可以如下更改弹出菜单的背景颜色。

  1. 在 styles.xml 弹出菜单中创建样式。

    <style name="PopupMenuStyle" parent="Theme.AppCompat.Light">
         <item name="android:background">@color/YourColor</item>
    </style>
    
  2. 将此主题设置为 toolbar.xml

    中的工具栏弹出式主题
     <android.support.v7.widget.Toolbar     
       xmlns:app="http://schemas.android.com/apk/res-auto"    
       xmlns:android="http://schemas.android.com/apk/res/android"
    
                // Your code here
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            app:popupTheme="@style/PopupMenuStyle" />
    

希望对你有用。