如何还原默认状态栏颜色? [英] How can I restore the default status bar color?

查看:80
本文介绍了如何还原默认状态栏颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一项活动中,我不希望状态栏显示任何颜色.我希望它保持在我的应用运行之前的任何颜色.

我可以将其更改为黑色,但是黑色不是默认设置,默认设置是透明的.我不想试图找到哪种透明度是正确的,因为在其他人的手机上透明度可能有所不同,所以我基本上不想在此特定活动中使用状态栏的颜色功能

  if(Build.VERSION.SDK_INT> = Build.VERSION_CODES.LOLLIPOP){窗口window = getWindow();window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);window.setStatusBarColor(Color.BLACK);} 

解决方案

默认情况下,标题栏使用 colorPrimaryDark (文档

In one of my activities, I don't want the status bar to have any color. I want it to stay in whichever color the is before my app is ran.

I can change it to black, but black isn't the default, the default is kind of transparent. I don't want tot try to find which transparency is the correct one because It might be different on other people's phones so I want to basically not use the color feature of the status bar in this particular activiy

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Window window = getWindow();
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.setStatusBarColor(Color.BLACK);
 }

解决方案

By default title bar is colored using colorPrimaryDark (docs here, see pic below). Or when you look at Material theme:

<item name="statusBarColor">?attr/colorPrimaryDark</item>

You should also see this posts

这篇关于如何还原默认状态栏颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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