Kalyaganov Alexey Kalyaganov Alexey - 1 month ago 24
Android Question

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>

Answer

This problem happened here even when i upgraded to 22.2.0.
I solved adding items without "android:" prefix to styles and adding style attribute in Toolbar element.

<android.support.v7.widget.Toolbar
  xmlns:android="http://schemas.android.com/apk/res/android"
  style="@style/ToolbarTheme"
  android:id="@+id/toolbar"
  android:layout_width="match_parent"
  android:layout_height="?attr/actionBarSize"
  android:elevation="6dp"/>  

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowBackground">@color/window_background</item>
    <item name="android:windowActionBar">false</item>

    <item name="android:windowActionModeOverlay">true</item>
    <item name="windowActionModeOverlay">true</item>

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

<style name="AppTheme" parent="AppTheme.Base">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>>
    <item name="colorAccent">@color/accent</item>
    <item name="colorButtonNormal">@color/primary</item>
</style>

<style name="ToolbarTheme" parent="Widget.AppCompat.Toolbar">
    <item name="android:background">@color/primary</item>
    <item name="background">@color/primary</item>
    <item name="titleTextAppearance">@style/ToolbarTitleTheme</item>
    <item name="popupTheme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
    <item name="theme">@style/ThemeOverlay.AppCompat.Dark.ActionBar</item>
</style>

<style name="ToolbarTitleTheme">
    <item name="android:textSize">@dimen/text_large</item>
    <item name="android:textColor">@android:color/white</item>
    <item name="android:textStyle">bold</item>
</style>
Comments