Android - 带有非透明导航栏的全透明状态栏

Android - 带有非透明导航栏的全透明状态栏

问题描述:

我一直在寻找一种在状态栏完全透明(不是半透明)的情况下重新着色导航栏的方法.使状态栏完全透明需要将布局标志设置为 NO_LIMITS,但这也会使导航栏失去颜色.有什么办法可以做到这一点吗?

I have been looking for a way to re-color the navigation bar while the status bar is fully transparent (not translucent). Getting the status bar to be completely transparent requires the layout flags to be set to NO_LIMITS but that also makes the navigation bar lose its color. Is there any way to achieve this?

如果你不需要状态栏文字变暗,下面的方法可行.

If you do not need the status bar text to be dark, the following works.

        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

并按照@JaviChaqués 的建议更改导航栏颜色.

And change the navigation bar color as @JaviChaqués suggest.