如何更改状态栏颜色以棒棒堂匹配的应用程序? [机器人] [英] How to change status bar color to match app in Lollipop? [Android]
问题描述
在新的棒棒糖更新我注意到,与天然谷歌应用程序的状态栏的颜色改变以匹配您正在运行的应用程序的操作栏。我认为这是对Twitter的应用程序也让我猜它不完全是谷歌谁可以做到这一点。
In the new lollipop update I noticed that with the native Google apps the color of the status bar changes to match the action bar on the app you're running. I see it's on the Twitter app also so I'm guessing it's not exclusively Google who can do it.
有谁知道如何做到这一点,如果这是可能的吗?
Does anyone know how to do this if it is possible?
推荐答案
要更改状态栏的颜色使用的 setStatusBarColor(INT颜色)。 据javadoc的,我们还需要在窗口上设置一些标志。
To change status bar color use setStatusBarColor(int color). According the javadoc, we also need set some flags on the window.
的code工作片段:
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(activity.getResources().getColor(R.color.example_color));
Keep in mind according Material Design guidelines status bar color and action bar color should be different:
- 的动作条的应该使用小学500色
- 的状态条的应该使用小学700色
- ActionBar should use primary 500 color
- StatusBar should use primary 700 color
看下面的截图:
这篇关于如何更改状态栏颜色以棒棒堂匹配的应用程序? [机器人]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!