如何更改状态栏颜色机器人 [英] How to change the status bar color in android
问题描述
首先其所有不重复的从<一个href="http://stackoverflow.com/questions/9044970/how-to-change-the-background-color-of-android-status-bar">How改变Android的状态栏的背景颜色
First of all its not a duplicates from How to change the background color of android status bar
如何我可以改变状态栏的颜色由颜色在导航栏中。
How to can i change the status bar color by which color have in navigation bar.
我想在状态栏的颜色基础上的导航栏的颜色
i want to the status bar color based on navigation bar color
推荐答案
更新:
棒棒糖:
public abstract void setStatusBarColor (int color)
加在API级别21
Added in API level 21
Android的棒棒堂带来了改变的状态栏的颜色在您的应用程序的更逼真的用户体验,并顺应了谷歌的材质设计准则的能力。
Android Lollipop brought with it the ability to change the color of status bar in your app for a more immersive user experience and in tune with Google’s Material Design Guidelines.
下面是你如何使用API级别引入的新window.setStatusBarColor方法更改状态栏的颜色21.
Here is how you can change the color of the status bar using the new window.setStatusBarColor method introduced in API level 21.
更改状态栏也需要在设置窗口另外两个标志的颜色;你需要添加FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS标志并清除FLAG_TRANSLUCENT_STATUS标志。
Changing the color of status bar also requires setting two additional flags on the Window; you need to add the FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag and clear the FLAG_TRANSLUCENT_STATUS flag.
工作code:
Window window = activity.getWindow();
// clear FLAG_TRANSLUCENT_STATUS flag:
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
// finally change the color
window.setStatusBarColor(activity.getResources().getColor(R.color.my_statusbar_color));
offcial:<一href="http://developer.android.com/reference/android/view/Window.html#setStatusBarColor(int)">http://developer.android.com/reference/android/view/Window.html#setStatusBarColor(int)
例:材质设计,处处
<一个href="https://chris.banes.me/2014/10/17/appcompat-v21/">https://chris.banes.me/2014/10/17/appcompat-v21/
在transitionName为视图背景将是安卓状态:背景
The transitionName for the view background will be "android:status:background
".
这篇关于如何更改状态栏颜色机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!