Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 512
Kalyaganov Alexey Avatar asked Nov 22 '14 21:11

Kalyaganov Alexey


2 Answers

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!

like image 189
Ray Hunter Avatar answered Oct 14 '22 09:10

Ray Hunter


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>
like image 27
Sandro Simas Avatar answered Oct 14 '22 10:10

Sandro Simas