更改材料设计AppCompat动作条颜色 [英] Change Material Design AppCompat ActionBar Color

查看:185
本文介绍了更改材料设计AppCompat动作条颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用来改变AppCompat状态栏的颜色与 actionBarStyle ,并创建一个背景,是我想要的颜色的样式。

I used to change AppCompat status bar color with actionBarStyle, and creating a style with a background which is the color I want.

现在,随着材料设计AppCompat,此方法不工作了。

Now, with Material Design AppCompat, this method doesn't work anymore.

您能帮我吗?谢谢你。

推荐答案

还有 colorPrimary 称为一个新的属性,你可以在你的主题定义。这会给你动作条或工具栏纯色。

There's a new attribute called colorPrimary which you can define in your Theme. This will give you ActionBar or Toolbar a solid color.

下面一个小例子:

<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">@color/my_action_bar_color</item>
</style>

请注意:它必须是唯一的 colorPrimary ,不是安卓colorPrimary 在每一个价值观文件夹以外的值-V21 之一。

Please note: It has to be only colorPrimary, not android:colorPrimary, in every values-folder except the values-v21 one.

您可以阅读更多有关自定义调色板上的<一个href="http://developer.android.com/training/material/compatibility.html#SupportLib">developer.android.com.

You can read more about customizing the Color Palette on developer.android.com.

这篇关于更改材料设计AppCompat动作条颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆