全屏和Lights-out模式

定义

在Android的说法中,全屏模式(Full-screen mode)意味着从屏幕上删除任何系统提供的“bars”:标题栏(title bar),操作栏(action bar),状态栏(status bar),系统栏(system bar),导航栏(navigation bar)等。您可以将其用于游戏,视频播放器,数字 书籍阅读者或其他在活动中花费的时间足够大的地方,可以取消一些正常的配额,以释放任何活动本身所在的空间

在Android说明中,点亮模式(Lights-out mode)是您使用系统栏(system bar)或导航栏(navigation bar)的位置,并使其中的小部件变暗,使得该栏仍然可用,但视觉分散程度较低。 这是一个在Android 3.0中添加的新概念,在Android 1.x或2.x中没有直接模拟。

Android 1.x/2.x

To have an activity be in full-screen mode, you have two choices:

  • 使用Theme.NoTitleBar.Fullscreen的主题(或从Theme.NoTitleBar.Fullscreen继承的一些自定义主题
  • 在调用setContentView()之前,onCreate()中执行以下语句:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                     WindowManager.LayoutParams.FLAG_FULLSCREEN);

The first statement removes the title bar or action bar.
The second statement indicates that you want the activity to run in full-screen mode, hiding the status bar.

Android 4.0+

全屏和Lights-out模式_第1张图片
Android 4.0 Display normal

Lights-out, or low-profile mode, is achieved by calling setSystemUiVisibility() with the View.SYSTEM_UI_FLAG_LOW_PROFILE flag. This will dim the navigation or system bar, so the bar is there and the buttons are still active, but that they are less visually intrusive:

全屏和Lights-out模式_第2张图片
Nexus 4/Android 4.2

You can temporarily hide the navigation bar (or system bar) by passing View.SYSTEM_UI_FLAG_HIDE_NAVIGATION to setSystemUiVisibility(). The bar will disappear, until the user touches the UI, in which case the bar reappears:

全屏和Lights-out模式_第3张图片
Nexus 4Android 4.2

Similarly, you can hide the status bar by passing View.SYSTEM_UI_FLAG_FULLSCREEN to setSystemUiVisibility(). However, despite this flag’s name, it does not affect the navigation or system bar:

全屏和Lights-out模式_第4张图片
Nexus 4/Android 4.2

Hence, to hide both the status bar and the navigation or system bar, you need to pass both flags (View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION):

全屏和Lights-out模式_第5张图片
Nexus 4/Android 4.2

你可能感兴趣的:(全屏和Lights-out模式)