Jacky's blog
首页
  • Android
  • Web
  • Server
  • Python
  • iOS
  • Java
  • Vue
  • 计算机基础
  • AI
  • 全部工具
  • CLI 工具
  • 编辑器
  • 开发工具
  • 构建工具
  • 版本控制
  • 调试工具
  • 网络工具
  • 个人成长
  • 博客
  • 分类
  • 标签
  • 归档
收藏
GitHub (opens new window)

Jack Yang

编程; 随笔
首页
  • Android
  • Web
  • Server
  • Python
  • iOS
  • Java
  • Vue
  • 计算机基础
  • AI
  • 全部工具
  • CLI 工具
  • 编辑器
  • 开发工具
  • 构建工具
  • 版本控制
  • 调试工具
  • 网络工具
  • 个人成长
  • 博客
  • 分类
  • 标签
  • 归档
收藏
GitHub (opens new window)
  • tutorial
  • Jetpack

  • 组件

  • AndroidX

  • 动态化
  • APM

  • 组件化

  • 鸿蒙

  • 工具

  • 其他

    • Flutter 高频面试问答
    • 生产环境Message分发处理设计
    • Android 事件分发机制
    • android沉浸式设置
    • Android 评论at功能的实现
    • 探索抖音禁止录屏
    • 对32位手机崩溃的优化记录
    • GradientDrawable
    • tutorial
    • color
    • webview白屏检测
    • android Resource
    • deeplink技术
    • android-xml
    • ANDROID IPC
    • BottomSheetBehavior研究与思考
    • viewPager
    • android window
    • Android密钥系统
    • compiler
    • Android 端口转发(Forward & Reverse) 的实操与避坑全指南
    • 提升UI加载速度的几点思考
    • Android零耗时首帧体验
    • jsbridge
    • retrofit动态代理设计
    • gif与属性动画的对比
  • Kotlin

  • android_snip
  • ANDROID 深度技术面试问答
  • android tool
  • android图形系统
  • android
  • other
Jacky
2026-03-17

android沉浸式设置

沉浸式隐藏系统 状态栏/导航栏。 参考官方文档 Hide system bars for immersive mode (opens new window)

val windowInsetsController =
        WindowCompat.getInsetsController(window, window.decorView)
// Configure the behavior of the hidden system bars.
windowInsetsController.systemBarsBehavior =
    WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

// Add a listener to update the behavior of the toggle fullscreen button when
// the system bars are hidden or revealed.
ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { view, windowInsets ->
    // You can hide the caption bar even when the other system bars are visible.
    // To account for this, explicitly check the visibility of navigationBars()
    // and statusBars() rather than checking the visibility of systemBars().
    if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars())
        || windowInsets.isVisible(WindowInsetsCompat.Type.statusBars())) {
        binding.toggleFullscreenButton.setOnClickListener {
            // Hide both the status bar and the navigation bar.
            windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
        }
    } else {
        binding.toggleFullscreenButton.setOnClickListener {
            // Show both the status bar and the navigation bar.
            windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
        }
    }
    ViewCompat.onApplyWindowInsets(view, windowInsets)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Android
上次更新: 2026/10/18, 22:14:48
Android 事件分发机制
Android 评论at功能的实现

← Android 事件分发机制 Android 评论at功能的实现→

最近更新
01
Codex 使用与会话管理指南
10-17
02
Tailscale 入门:让自己的设备跨网络互联
10-15
03
GitHub CLI(gh)工作流与 CI 排查
10-08
更多文章>
Theme by Vdoing | Copyright © 2019-2026 Jacky | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式