具有不透明导航栏的深色文本透明状态栏 [英] Dark-text transparent status bar with opaque navigation bar

查看:131
本文介绍了具有不透明导航栏的深色文本透明状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处提出了类似的问题,但未解决深色文本状态栏.

A similar question has been asked here, but not addressing dark-text status bar.

我想同时实现三件事:

  1. 透明状态栏(不隐藏它!)
  2. 深色状态栏
  3. 不透明(或黑色)导航栏(不允许活动内容在其下方膨胀)

我尝试过的

解决方案

What I have tried

The solution

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

只能达到1和3;

此处的解决方案只能达到1和2;

而解决方案此处只能达到2和3....

And the solution here can only achieve 2 and 3....

那么有没有办法实现所有1、2和3?!

So is there a way to achieve all 1, 2 an 3?!

推荐答案

内部styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="android:navigationBarColor">@android:color/black</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

活动中的onCreate():

override fun onCreate(savedInstanceState: Bundle?) {
  window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
  super.onCreate(savedInstanceState)
  setContentView(R.layout.activity_main)
}

会导致以下结果:

这篇关于具有不透明导航栏的深色文本透明状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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