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以上。
相关文章
相关标签/搜索