微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android 全屏无法通过文档工作

如何解决Android 全屏无法通过文档工作

我遵循了这个文档:

https://developer.android.com/training/system-ui/immersive#EnableFullscreen

这是我的代码

class SplashActivity : BaseBindingActivity<ActivitySplashBinding,Splashviewmodel>() {

    override fun getLayout() = R.layout.activity_splash

    override fun onWindowFocusChanged(hasFocus: Boolean) {
        super.onWindowFocusChanged(hasFocus)
        if (hasFocus) hidesystemUIs()
    }

    private fun hidesystemUIs() {
        window.decorView.systemUIVisibility = (View.SYstem_UI_FLAG_IMMERSIVE
                or View.SYstem_UI_FLAG_LAYOUT_STABLE
                or View.SYstem_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                or View.SYstem_UI_FLAG_LAYOUT_FULLSCREEN
                or View.SYstem_UI_FLAG_HIDE_NAVIGATION
                or View.SYstem_UI_FLAG_FULLSCREEN)
    }
}



<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="logo"
        android:textSize="38sp"
        android:textColor="@color/white"/>

</RelativeLayout>

但结果很糟糕,状态栏不见了,但内容是透明的

enter image description here

更新 我发布了发布版本,但我也有一个测试,该构建正在运行,但是没有区别!我检查了布局检查器,android.R.id.statusBarBackground 视图是 0dp :O

释放风味

enter image description here

测试口味

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。