How can I change text/icon color in Action Mode?
Asked Answered
P

1

10

First of all, I'm trying a lot of examples that I've found here, but anything work for me.

At the moment, I can only change the color background of my Action Mode, but not the text color and the color of the icon to come back

Some help will be appreciated!

This is what I'm trying:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="actionModeStyle">@style/Style.ActionMode</item>
    </style>

<!-- *************************** Custom ActionMode Bar **************************************-->
    <style name="Style.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
        <item name="background">@color/color_action_mode_bg</item>
        <item name="android:backgroundSplit">?android:attr/actionModeSplitBackground</item>
        <item name="android:height">?android:attr/actionBarSize</item>
        <item name="android:titleTextStyle">@style/Stl.TitleTextStyle</item>
    </style>

    <style name="Stl.TitleTextStyle" parent="@style/Widget.AppCompat.ActionMode">
        <item name="android:textColor">@color/colorPrimary</item>
    </style>
Pentavalent answered 12/8, 2016 at 11:4 Comment(0)
E
26

Use following snippet to change ActionMode background color + Title Color + Back Button Color

styles.xml

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

<style name="ActionModeTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionMode.Title">
    <item name="android:textColor">@android:color/white</item>
</style>

themes.xml

<item name="actionModeStyle">@style/ActionModeStyle</item>
<item name="actionBarTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>

Please Note: actionBarTheme will be responsible for setting back button color to white.

Eject answered 8/9, 2016 at 11:28 Comment(2)
Is there a way to change the color of the action mode icons via xml without using a different drawable?Jameson
@style/Widget.AppCompat.ActionMode this style works for me.Calculate

© 2022 - 2024 — McMap. All rights reserved.