Android 4.4 translucent Status and Navigation bars style on Android 5.0

前端 未结 3 542
悲&欢浪女
悲&欢浪女 2020-12-13 00:12

On Android 4.4 KitKat you can set the Status and Navigation bars transparent with the android:windowTranslucentStatus and android:windowTranslucentNavigat

相关标签:
3条回答
  • 2020-12-13 00:57

    Set android:windowTranslucentStatus to false and set android:statusBarColor to @android:color/transparent.

    Then add code below:

    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    

    If you also want the navigation bar to be translucent, set android:navigationBarColor to @android:color/transparent and combine the flag View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION as well.

    I didn't experiment on the navigation bar but it will work.

    0 讨论(0)
  • 2020-12-13 01:05

    To clarify @suckgamony's answer to this question:

    • Under Lollipop and above, setting android:statusBarColor or android:navigationBarColor to @android:color/transparent will make the Status Bar or Navigation Bar (respectively) completely transparent, unless:
    • android:windowTranslucentStatus or android:windowTranslucentNavigation is set to true, in which case the Status Bar or Navigation Bar (respectively) is set to the solid transparent color @AxeEffect describes (again, under Lollipop and above);
    • android:statusBarColor and android:navigationBarColor may only be used with Android version 21 (Lollipop 5.0) or higher. As described in the referred to answer, android:windowTranslucentStatus or android:windowTranslucentNavigation when used with Kitkat provide transparent gradients rather than full transparency.
    0 讨论(0)
  • 2020-12-13 01:06

    Add below line to your style:

    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
    
    0 讨论(0)
提交回复
热议问题