AppCompat 21 ActionBar ActionMode color

when entering actionmode in AppCompat 21, my ActionBar turns gray - no colors are used:

<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/secondary</item>
<item name="color">@color/secondary</item>

      

I think I am just missing the correct name to set this color, but I cannot see anything in action.

+3


source to share


2 answers


The ActionMode doesn't accept the colors you defined in the primaryColor (at least not yet). To set the color of the ActionMode you just need to define it yourself, for example:

<item name="actionModeBackground">@color/primary</item>

      



Or more generally, which is better if you support different color themes in the same application:

<item name="actionModeBackground">?attr/colorPrimary</item>

      

+9


source


Actionbar has been deprecated in API 21. You need to use a toolbar instead .

if you still want to get style.xml here is styles.xml example with correct name



<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
    <!-- Customize your theme here. -->
    <item name="windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>

    <!-- Actionbar color -->
    <item name="colorPrimary">@color/accent_material_dark</item>
    <!--Status bar color-->
    <item name="colorPrimaryDark">@color/accent_material_light</item>
    <!--Window color-->
    <item name="android:windowBackground">@color/dim_foreground_material_dark</item>
</style>

      



0


source







All Articles