Android沉浸式Translucent System Bar

Android沉浸式Translucent System Bar

Android沉浸式APP主要是用在Android 4.4以上纔會有效果。 也就是api-19+android

什麼是沉浸式。 以下圖:api

JAVA icon

能夠看到第一幅圖上面的狀態欄和底下的虛擬按鍵都變成藍色,比第二張圖效果好一些。因此這個就是沉浸式效果app

沉浸式效果只能支持Android api 19以上也就是 Android 4.4以上。可是低版本的適配怎麼辦。code

請注意咱們能夠創建 3個文件夾分別爲value value-v19 value-v21 來進行適配xml

  • value 表明適配Android4.4之前的,styles.xml內容以下:
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!--Theme.AppCompat.Light.DarkActionBar-->
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>
  • value-v19 適配api-19 Android4.4以上。
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!--Theme.AppCompat.Light.DarkActionBar-->
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>

        <item name="android:windowTranslucentStatus">false</item>
        <item name="android:windowTranslucentNavigation">false</item>
    </style>
</resources>
  • value-v21 適配Android5.0以上。
相關文章
相關標籤/搜索