Search code examples
androidandroid-support-libraryandroid-actionmode

Android ActionMode title background color


I`m using new android support library 21.0.2 and when i call ActionMode for text selection i got this.

Bug or feature

It seems than title textview background is transparent.

Redefining titleTextStyle of ActionMode has no effect.

Any suggestions? Thanks.

theme.xml

    <item name="actionModeStyle">@style/ActionMode</item>
    <item name="android:actionModeStyle">@style/ActionMode</item>

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

    <style name="ActionModeTitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionMode.Title">
        <item name="android:background">#ff0000</item>
        <item name="android:colorBackground">#ff0000</item>
    </style>

Solution

  • I ran into this issue using the the AppBarLayout with the Toolbar and TabLayout. I had set the background color on the Toolbar and that caused the ActionMode title to display the background color of the Toolbar and not the actionModeBackground color that was set on the Theme.

    I moved the background color to the AppBarLayout instead and this fixed the issue with the title having the background color of the Toolbar.

    Hope this helps someone!