Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 834
S.P. Avatar asked Aug 12 '16 11:08

S.P.


Video Answer


1 Answers

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.

like image 92
Vipul Avatar answered Nov 03 '22 22:11

Vipul