简体   繁体   中英

AppCompat 21 ActionBar ActionMode color

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.

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>

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM