Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

statusbar - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...