简体   繁体   English

仅状态栏透明,而不是导航栏

[英]Only Status bar Transparent, not a Navigation bar

I want to set a transparent status bar, not a navigation bar. 我想设置一个透明的状态栏,而不是导航栏。

what I tried 我尝试过的

window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)

But it set Status bar and navigation bar both transparent. 但是它将状态栏和导航栏都设置为透明。 I want only Status bar transparent 我只希望状态栏透明

I also want to set different status bar color based on Fragment, And my navigation drawer is an overriding status bar, like this 我也想基于Fragment设置不同的状态栏颜色,而我的导航抽屉是一个覆盖状态栏,像这样

在此处输入图片说明

Set these properties in your theme: 在主题中设置以下属性:

<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>

And in your layout you want to have a transparent status bar, set below attribute: 并且在您的布局中,您希望有一个透明的状态栏,在下面的属性中进行设置:

android:fitsSystemWindows="true"

On Lolipop and above: 在Lolipop及更高版本上:

window.statusBarColor = ContextCompat.getColor(this, android.R.color.transparent)

And on Marshmallow and above for transparent status with dark icons 并在棉花糖及更高版本上以深色图标显示透明状态

window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR

or transparent status with light icons 或带有指示灯的透明状态

window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM