android-fullscreen - 如何退出沉浸式模式并返回默认的 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
}
当我进入片段时,粘性沉浸模式有效,但是当它被破坏时,状态栏和应用栏之间存在间隙。它看起来像这样:
应用栏还覆盖了屏幕上的一些文本视图。当片段被销毁时,如何正确退出粘性沉浸模式并将其恢复为默认行为?
解决方案
推荐阅读
- c# - 如何调整 ListBoxItems 的大小以适合容器?
- java - Spring @Qualifer 不与实现多个接口的 Bean 一起使用
- git - Git - 从分支的历史记录中删除文件
- android - 致命异常 android.view.InflateException:布局/activity_main 中的二进制 XML 文件行 #291:二进制 XML 文件行
- deep-learning - 当我们进行微调任务时,Bert 如何改变最大序列长度?
- c# - Microsoft Entity Framework 不保存更改
- jquery - AngularJS 拆分器示例
- slurm - 排队 SLURM 作业以在 X 分钟后运行
- javascript - 使用 Vue.js 在 Laravel 中上传多张图片
- c# - 带有 asp.net Core Identity 的 Microsoft Identity Pltaform