Controls for system UI visibility

Since the early days of Android, the system has managed a UI component known as thestatus bar, which resides at the top of handset devices to deliver information such as the carrier signal, time, notifications, and so on. Android 3.0 added thesystem barfor tablet devices, which resides at the bottom of the screen to provide system navigation controls (Home, Back, and so forth) and also an interface for elements traditionally provided by the status bar. In Android 4.0, the system provides a new type of system UI called thenavigation bar. You might consider the navigation bar a re-tuned version of the system bar designed for handsets—it provides navigation controls for devices that don’t have hardware counterparts for navigating the system, but it leaves out the system bar's notification UI and setting controls. As such, a device that provides the navigation bar also has the status bar at the top.

To this day, you can hide the status bar on handsets using theFLAG_FULLSCREENflag. In Android 4.0, the APIs that control the system bar’s visibility have been updated to better reflect the behavior of both the system bar and navigation bar:

  • TheSYSTEM_UI_FLAG_LOW_PROFILEflag replaces theSTATUS_BAR_HIDDENflag. When set, this flag enables “low profile" mode for the system bar or navigation bar. Navigation buttons dim and other elements in the system bar also hide. Enabling this is useful for creating more immersive games without distraction for the system navigation buttons.
  • TheSYSTEM_UI_FLAG_VISIBLEflag replaces theSTATUS_BAR_VISIBLEflag to request the system bar or navigation bar be visible.
  • TheSYSTEM_UI_FLAG_HIDE_NAVIGATIONis a new flag that requests the navigation bar hide completely. Be aware that this works only for thenavigation barused by some handsets (it doesnothide the system bar on tablets). The navigation bar returns to view as soon as the system receives user input. As such, this mode is useful primarily for video playback or other cases in which the whole screen is needed but user input is not required.

You can set each of these flags for the system bar and navigation bar by callingsetSystemUiVisibility()on any view in your activity. The window manager combines (OR-together) all flags from all views in your window and apply them to the system UI as long as your window has input focus. When your window loses input focus (the user navigates away from your app, or a dialog appears), your flags cease to have effect. Similarly, if you remove those views from the view hierarchy their flags no longer apply.

To synchronize other events in your activity with visibility changes to the system UI (for example, hide the action bar or other UI controls when the system UI hides), you should register aView.OnSystemUiVisibilityChangeListenerto be notified when the visibility of the system bar or navigation bar changes.

See theOverscanActivityclass for a demonstration of different system UI options.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android应用的灵魂:Intent 和Activity
  2. Android Studio 问题解决记录
  3. Android广播接收者应用(电话拦截器)
  4. 成功为Android系统配上了GNU开发环境
  5. Android应用程序安装过程浅析
  6. Android(安卓)TextView 富文本 Spannable
  7. android opengl 画球 画圆
  8. Android TextUtils.isEmpty()的误解
  9. Android(安卓)gradle和gradle插件配置
  10. Android 文件及文件夹删除