全屏和Lights-out模式

定義

在Android的說(shuō)法中,全屏模式(Full-screen mode)意味著從屏幕上刪除任何系統(tǒng)提供的“bars”:標(biāo)題欄(title bar),操作欄(action bar),狀態(tài)欄(status bar),系統(tǒng)欄(system bar),導(dǎo)航欄(navigation bar)等。您可以將其用于游戲,視頻播放器,數(shù)字 書籍閱讀者或其他在活動(dòng)中花費(fèi)的時(shí)間足夠大的地方,可以取消一些正常的配額,以釋放任何活動(dòng)本身所在的空間

在Android說(shuō)明中,點(diǎn)亮模式(Lights-out mode)是您使用系統(tǒng)欄(system bar)或?qū)Ш綑?navigation bar)的位置,并使其中的小部件變暗,使得該欄仍然可用,但視覺(jué)分散程度較低。 這是一個(gè)在Android 3.0中添加的新概念,在Android 1.x或2.x中沒(méi)有直接模擬。

Android 1.x/2.x

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

  • 使用Theme.NoTitleBar.Fullscreen的主題(或從Theme.NoTitleBar.Fullscreen繼承的一些自定義主題
  • 在調(diào)用setContentView()之前,onCreate()中執(zhí)行以下語(yǔ)句:
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+

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:

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:

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:

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):

Nexus 4/Android 4.2
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容