3

when entering actionmode in AppCompat 21 my ActionBar gets grey - the colors are not 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 right name for setting this color - but there is nothing with action as far as I see.

ligi
  • 35,518
  • 37
  • 123
  • 220

2 Answers2

9

ActionMode does not take the colors you defined in primaryColor (at least for now). To set the color of the ActionMode, you just need to define it by your own, like:

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

Or in a more generic way, which is better if you support different color themes in one app:

<item name="actionModeBackground">?attr/colorPrimary</item>
Qianqian
  • 2,044
  • 15
  • 27
  • This has helped me great deal! Thanks – nLL Nov 26 '14 at 09:02
  • @Qianqian, do you know how to change status bar color of ActionMode? – Charlesjean Jan 10 '15 at 12:51
  • @Charlesjean, What do you mean by the status bar color of ActionMode? The status bar is always there and if you are on Android 5, you should be able to change it by call setStatusBarColor method from the activity code. – Qianqian Jan 11 '15 at 05:47
0

Actionbar is deprecated in API 21.You need to use Toolbar instead.

if you still want to get a styles.xml, here is a sample styles.xml 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>

Community
  • 1
  • 1
Miao1007
  • 826
  • 6
  • 20