简体   繁体   English

AppCompat 21 ActionBar ActionMode颜色

[英]AppCompat 21 ActionBar ActionMode color

when entering actionmode in AppCompat 21 my ActionBar gets grey - the colors are not used: 当在AppCompat 21中输入actionmode时,我的ActionBar变为灰色 - 不使用颜色:

<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). ActionMode不会采用您在primaryColor中定义的颜色(至少目前为止)。 To set the color of the ActionMode, you just need to define it by your own, like: 要设置ActionMode的颜色,您只需要自己定义它,例如:

<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. API 21中不推荐使用Actionbar。您需要使用工具栏

if you still want to get a styles.xml, here is a sample styles.xml with correct name 如果你仍想获得styles.xml,这里有一个样本styles.xml,名称正确

<!-- 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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