更改状态/下方21 API的Andr​​oid通知栏的颜色? [英] Change status / notification bar color on api below 21 android?

查看:189
本文介绍了更改状态/下方21 API的Andr​​oid通知栏的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到了一些应用程序的状态栏的颜色可以改变,并能满足如什么是API级别21正在做。

我搜索,发现这个解决方案
<一href=\"http://stackoverflow.com/questions/27093287/how-to-change-status-bar-color-to-match-app-in-lollipop-android\">Source

 &LT;样式名称=Theme.MyTheme父=Theme.AppCompat.Light&GT;
&LT;! - 设置应用程序兼容性的颜色主题化的attrs - &GT;
&LT;项目名称=colorPrimary&GT; @彩色/ my_awesome_red&LT; /项目&GT;
&LT;项目名称=colorPrimaryDark&GT; @彩色/ my_awesome_darker_red&LT; /项目&GT;
&LT;! - 其他属性 - &GT;
&LT; /风格&GT;

但它不工作

这是我的风格code

 &LT;样式名称=ToolbarTheme父=Theme.AppCompat&GT;
    &LT;项目名称=机器人:windowNoTitle&GT;真&LT; /项目&GT;
    &LT;项目名称=windowActionBar&GT;假LT; /项目&GT;
    &LT;项目名称=colorPrimary&GT; @彩色/ ColorPrimary&LT; /项目&GT;
    &LT;项目名称=colorPrimaryDark&GT; @彩色/ ColorPrimaryDark&LT; /项目&GT;
&LT; /风格&GT;


解决方案

如果你的意思是AcionBar的颜色,您可以通过编程改变这个code的颜色:

  getSupportActionBar()setBackgroundDrawable(新Color.Drawable(Color.rgb(120,0,47)))。

更改号码来选择自己的颜色。

我希望它为你的作品!

问候。

I have seen in some apps the status bar color could be changed and matched to as what is being done in api level 21.

I searched and found this solution Source

<style name="Theme.MyTheme" parent="Theme.AppCompat.Light">   
<!-- Set AppCompat’s color theming attrs -->
<item name="colorPrimary">@color/my_awesome_red</item>
<item name="colorPrimaryDark">@color/my_awesome_darker_red</item>
<!-- Other attributes -->
</style>

But it is not working

This is my style code

<style name="ToolbarTheme" parent="Theme.AppCompat">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/ColorPrimary</item>
    <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
</style>

解决方案

If you mean the color of AcionBar, you can change programmatically the color with this code:

getSupportActionBar().setBackgroundDrawable(new Color.Drawable(Color.rgb(120,0,47)));

Change numbers to select your own color.

I hope it works for you!

Regards.

这篇关于更改状态/下方21 API的Andr​​oid通知栏的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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