0

Starting from Material3 I can not change the action mode background color.

Before Material3, I managed to change the background color with actionModeBackground attribute:

<item name="actionModeBackground">@color/some_color</item>

Here is my theme:

<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionModeOverlay">false</item>
    <item name="actionModeBackground">@color/action_mode_background</item>
    <item name="android:actionModeCloseDrawable">@drawable/ic_baseline_done_tick_24</item>
</style>

I also checked this thread but doesn't seem to work for material3.

How can I change the action mode background color with Material3?

Zain
  • 37,492
  • 7
  • 60
  • 84

1 Answers1

0

You can use the actionModeStyle style attribute to set a custom style to the Action Mode, and then change the action mode background with background attribute:

<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
    ...
    <item name="actionModeStyle">@style/action_mode_style</item>    

</style>

<style name="action_mode_style" parent="@style/Widget.Material3.ActionMode">
    <item name="background">@color/action_mode_background</item>
</style>
Zain
  • 37,492
  • 7
  • 60
  • 84