0

In Android, is there any way to give an ActionMode the same appearance as the normal Toolbar? Currently my ActionMode looks different to the Toolbar in that the background is slightly brighter (at least using Theme.AppCompat.NoActionBar), the MenuItems are fully black/white (depending on the theme) instead of colorControlNormal (which I set them to) and most annoyingly, there is an underline under the ActionMode that I can't seem to get rid of. Instead, I'm trying to make the ActionMode indistinguishable from the Toolbar.

The Toolbar (also what the ActionMode is meant to look like): Toolbar

What the ActionMode currently looks like: ActionMode

Any help would be highly appreciated!

4

1 回答 1

1
  1. 用于更改ActionMode& 删除底线的背景颜色。您可以使用actionModeStyle可以设置background为所需颜色的位置。
  2. 要更改图标颜色,您可以colorControlNormalactionBarTheme.

所以你的主题看起来像这样:

<style name="Theme.AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

        <!--add this-->
        <item name="actionModeStyle">@style/ActionModeStyle</item>
        <item name="actionBarTheme">@style/MyActionBarTheme</item>

    </style>

    <style name="MyActionBarTheme" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
        //replace with your own desired color
        <item name="colorControlNormal">#a00</item>
    </style>

    <style name="ActionModeStyle" parent="@style/Widget.AppCompat.ActionMode">
        //replace with your own desired color
        <item name="background">@color/colorPrimary</item>
        <item name="titleTextStyle">@style/ActionModeTitleTextStyle</item>
    </style>

    <style name="ActionModeTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionMode.Title">
        //replace with your own desired color
        <item name="android:textColor">#a00</item>
    </style>
于 2021-05-02T09:12:48.667 回答