问题描述
我正在尝试将状态栏的颜色更改为带有灰色图标的白色.我已经尝试了几乎所有针对此问题的代码解决方案,但没有一个对我有用.
i am trying to change color of my status bar to white with grey icons. i have tried almost every code solution for this problem but non of them worked for me.
我正在使用此Java功能对其进行更改,并且我还发布了style(21)代码.
i am using this java fucntion to change it and i am also posting my style(21) code.
public static void statusBarColor(Window window, Context ctx) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//Window window = getActivity().getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(ctx.getResources().getColor(R.color.statusbar_color));
}
}
这是我的Java代码,但经过一千次尝试后无法正常工作.下面是我的style.xml(21)
this is my java code but its not working after thousand tries.and below is my style.xml (21)
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar" tools:targetApi="23">true</item>
</style>
如果您认为它是其他问题的重复,那么我现在应该让您尝试3,4页的Google搜索并实施它们.
if you think its duplicate of some other question then i should let you now i have tried 3,4 pages of google search and also implemented them.
推荐答案
使用此标志可以实现:
<item name="android:windowLightStatusBar">true</item>
不幸的是,它可以从API 23开始使用,因此您必须在values-v23/styles.xml
中指定它.有关更多信息,请参见此.
Unfortunately it's available from API 23 upwards, so you have to specify it in values-v23/styles.xml
. See this for more info.
此功能没有任何支持,因此在编写此功能时,它不能在任何较低版本的23上使用.
There is not any backport of this functionality, therefore it won't work on any lower 23 at the time of writing this.
这篇关于如何将android状态栏颜色更改为白色并将状态栏图标颜色更改为灰色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!