AxeEffect AxeEffect - 4 months ago 12
Android Question

Android 4.4 translucent Status and Navigation bars style on Android 5.0

On Android 4.4 KitKat you can set the Status and Navigation bars transparent with the

android:windowTranslucentStatus
and
android:windowTranslucentNavigation
theme elements, and then below the bars the app window is extended and a gradient is added. However on Android 5.0 Lollipop this has been changed and now instead of the gradient a solid transparent color is added. Android 5.0 offers the new
android:statusBarColor
and
android:navigationBarColor
elements under the new Material theme, but when you try to set these elements to
@android:color/transparent
the app window is not extended, and if you use
android:windowTranslucentStatus
and
android:windowTranslucentNavigation
then
android:statusBarColor
and
android:navigationBarColor
are ignored.

Am I missing something described on http://developer.android.com/training/material/theme.html#StatusBar?

enter image description here

Answer

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.

Comments