在 Android 中更改 ActionMode 背景颜色时遇到问题

Having trouble changing the ActionMode background color in Android

我的 ActionMode 菜单显示为纯白色,我不知道为什么。 我有一个 ActionMode menu.xml,它只有一个删除选项:

<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:id="@+id/action_delete"
          android:title="Delete"
          android:icon="@android:drawable/ic_menu_delete"/>

</menu>

我有一个应用到我的整个应用程序的主题,在 styles.xml:

中定义
<resources>

    <!-- Base application theme -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/paletteLightBlue3</item>
        <item name="colorPrimaryDark">@color/dark_grey</item>
        <item name="colorAccent">@color/paletteLightBlue</item>
        <item name="android:actionModeStyle">@style/aModeBg</item>
    </style>

    <style name="aModeBg" parent="@style/Widget.AppCompat.ActionMode">
        <item name="android:actionModeBackground">@color/dark_red</item>
    </style>

</resources>

如您所见,我已尝试将 actionModeBackground 属性 设置为深红色,但它仍然显示为白色。谁能帮忙?谢谢

好的所以我通过简单地这样做解决了这个问题:

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/paletteLightBlue3</item>
    <item name="colorPrimaryDark">@color/dark_grey</item>
    <item name="colorAccent">@color/paletteLightBlue</item>
    <item name="android:actionModeBackground">@color/dark_red</item>
</style>

我只是在我的 AppTheme 中设置了 actionModeBackground,而不是单独的样式。简单。