Android 沈浸式全屏

來源:互聯網
上載者:User

標籤:

Android 4.4 帶來了沈浸式全屏體驗, 在沈浸式全螢幕模式下, 狀態列、 虛擬按鍵動態隱藏, 應用可 以使用完整的螢幕空間, 按照 Google 的說法, 給使用者一種 “身臨其境” 的體驗。

Android 4.4 中提供了 IMMERSIVE 和 IMMERSIVE_STICKY 標記, 可以用這兩個標記與 SYSTEM_UI_FLAG_HIDE_NAVIGATION 和SYSTEM_UI_FLAG_FULLSCREEN 一起使用, 來實現沉 浸模式。

注意: 這些標 記在Xamarin.Android 中被映射為  Android.Views.SystemUiFlags 枚舉。普通全螢幕模式 (Fullscreen)

普通全螢幕模式通過設定下面的標記位實現:

var uiOpts = SystemUiFlags.LayoutStable        | SystemUiFlags.LayoutHideNavigation        | SystemUiFlags.LayoutFullscreen        | SystemUiFlags.Fullscreen        | SystemUiFlags.HideNavigation;Window.DecorView.SystemUiVisibility = uiOpts;

在普通全螢幕模式下, 應用可以佔據螢幕的全部空間, 當使用者觸控螢幕幕的任何部分時, 會自動結束全屏模 式, 這種模式比較適用於視頻播放器類應用。

沉浸模式 (Immersive)

沉浸模式通過設定下面的標記位實現:

var uiOpts = uiOpts = SystemUiFlags.LayoutStable        | SystemUiFlags.LayoutHideNavigation        | SystemUiFlags.LayoutFullscreen        | SystemUiFlags.Fullscreen        | SystemUiFlags.HideNavigation        | SystemUiFlags.Immersive;Window.DecorView.SystemUiVisibility = uiOpts;

在沉浸模式下, 應用佔據螢幕的全部空間, 只有當使用者從螢幕的上方邊沿處向下划動時, 才會退出沉浸 模式, 使用者觸控螢幕幕其它部分是, 不會退出該模式, 這種模式比較適用於閱讀器、 雜誌類應用。

黏性沉浸模式 (Sticky Immersive)

黏性沉浸模式通過設定下面的標記位來實現:

uiOpts = SystemUiFlags.LayoutStable        | SystemUiFlags.LayoutHideNavigation        | SystemUiFlags.LayoutFullscreen        | SystemUiFlags.Fullscreen        | SystemUiFlags.HideNavigation        | SystemUiFlags.ImmersiveSticky;Window.DecorView.SystemUiVisibility = uiOpts;

在黏性沉浸模式下, 應用使用螢幕的全部空間, 當使用者從螢幕的上方邊沿處向下滑動時, 也不會退出該 模式, 但是系統介面 (狀態列、 導覽列) 將會以半透明的效果浮現在應用視圖之上 (如所示), 只有當使用者點擊系統介面上的控制項時, 才會退出黏性沉浸模式。 因此, 這種全螢幕模式使用與遊戲、 繪 圖類應用。

根據 Android 開發文檔中提到, 應用在使用沉浸模式時最好將 ActionBar 設定為 Overlay 模式, 具體設定可以參考這裡:https://developer.android.com/training/basics/actionbar/overlaying.html

 

轉自:http://beginor.github.io/2014/06/27/android-immersive-mode.html

Android 沈浸式全屏

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.