Android ActionMode title background color
Asked Answered
P

2

9

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>
Pinup answered 22/11, 2014 at 21:8 Comment(3)
The same here, did you solve this?Despotic
@SandroSimas hmm.. actualy this issue dissapear after i update android support library to 22.2.0Pinup
+ for image content xDHeymann
G
5

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!

Gahnite answered 26/10, 2016 at 4:7 Comment(0)
D
4

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>
Despotic answered 15/7, 2015 at 17:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.