如何退出沉浸模式并返回默认的 Android UI 布局?

问题描述

我正在尝试在我的一个片段中使用粘性沉浸式模式。然后当片段被销毁时,返回到认的 UI 视图。

这是我的代码

override fun onViewCreated(view: View,savedInstanceState: Bundle?) {
        super.onViewCreated(view,savedInstanceState)

    hidesystemUI()
}

override fun onDestroyView() {
    super.onDestroyView()
    showsystemUI()
}

private fun hidesystemUI() {
    activity?.window?.decorView?.systemUIVisibility = (View.SYstem_UI_FLAG_IMMERSIVE_STICKY
            // Set the content to appear under the system bars so that the
            // content doesn't resize when the system bars hide and show.
            or View.SYstem_UI_FLAG_LAYOUT_STABLE
            or View.SYstem_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            or View.SYstem_UI_FLAG_LAYOUT_FULLSCREEN
            // Hide the nav bar and status bar
            or View.SYstem_UI_FLAG_HIDE_NAVIGATION
            or View.SYstem_UI_FLAG_FULLSCREEN)
}

private fun showsystemUI() {
    activity?.window?.decorView?.systemUIVisibility = View.SYstem_UI_FLAG_VISIBLE
}

当我进入片段时,粘性沉浸模式有效,但当它被销毁时,状态栏和应用程序栏中会出现间隙。它看起来像这样:

enter image description here

应用栏也覆盖了屏幕上的一些文本视图。如何正确退出粘性沉浸模式并在片段销毁时将其恢复为认行为?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...