[Points] Immersive Mode

本文详细介绍Android 4.4(API level 19)中引入的沉浸式全屏模式,包括使用view.setSystemUiVisibility()结合SYSTEM_UI_FLAG_IMMERSIVE与其他标志实现不同沉浸式效果的方法。文中还探讨了如何通过手势识别等方式使系统栏暂时显示或隐藏。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Using Immersive Full-Screen Mode

  • android 4.4(Api level 19) introduce
  • view.setSystemUiVisibility() SYSTEM_UI_FLAG_IMMERSIVE combine with SYSTEM_UI_FLAG_HIDE_NAVIGATION and SYSTEM_UI_FLAG_FULLSCREEN
  • reveal the system bars with an inward swipe along the region where the system bars normally appear(clean hide_navigation and full_screen flag)
  • system bars auto hide after a few moments, use SYSTEM_UI_FLAG_IMMERSIVE_STICKY

   

Immersive mode states:

  • Non-immersive mode the user swipes to display the system bars,clearing the SYSTEM_UI_FLAG_HIDE_NAVIGATION and SYSTEM_UI_FLAG_FULLSCREEN flags.View.OnSystemUiVisibilityChangeListener() to watch for ui changes
  • Reminder bubble guide for first time users enter immersive mode in your app
  • Immersive mode system bars hidden
  • Sticky flag use IMMERSIVE_STICKY flag and Semi-transparent bars temporarily appear and then hide again. The act of swiping doesn't clear any flags.

Note immersive mode take effect if you use immersive flag conjunction with SYSTEM_UI_FLAG_HIDE_NAVIGATION,SYSTEM_UI_FLAG_FULLSCREEN or both

Choose an Approach

  • building a book reader,news reader or a magazine,use the IMMERSIVE flag is good option.Because users may want to access the action bar and other UI controls somewhat frequently
  • expect users to interact near the edges of the sceen and you don't expect them to need frequent access to the system ui use the IMMERSIVE_STICKY flag
  • lean back style touch anywhere back tools.

Use Non-Sticky Immersion

  • include other system Ui flags(such as SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION and SYSTEM_UI_FLAG_LAYOUT_STABLE) to keep the content from resizing when the system bars hide and show.
  • register a listener described in Responding to UI Visibility Changes
  • Implement onWindowFocusChanged().If you lose window focus, for example due to a dialog or pop up menu showing above your app, you'll probably want to cancel any pending "hide" operations you previously scheduled with Handler.postDelayed() or something similar.
  • Implement a GestureDetector that detects onSingleTapUp(MotionEvent), to allow users to manually toggle the visibility of the system bars by touching your content.

Use Sticky Immersion

  • an inward swipe in the system bars areas causes the bars to temporarily appear in a semi-transparent state but ni flags are cleared
  • If you like the auto-hiding behavior of IMMERSIVE_STICKY but need to show your own UI controls as well, just use IMMERSIVE combined with Handler.postDelayed() or something similar to re-enter immersive mode after a few seconds.

NOTE watch the video DevBytes: Android 4.4 Immersive Mode]

转载于:https://www.cnblogs.com/jsaint/articles/3460465.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值