在Android 5.0的Andr​​oid 4.4半透明状态和导航栏样式样式、状态、Android、Andr

2023-09-12 07:11:19 作者:操逼不带套

在Android 4.4奇巧,您可以设置状态栏和导航栏透明与安卓windowTranslucentStatus 安卓windowTranslucentNavigation 主题元素,然后下面条的应用程序窗口,延长和梯度增加。然而在Android 5.0棒棒糖这已被改变,而不是现在梯度实心透明颜色被添加。安卓5.0提供了新的安卓statusBarColor 安卓:在新材料主题navigationBarColor 元素,但是当你尝试设置这些元素 @android:彩色/透明应用程序窗口没有延长,而如果使用安卓windowTranslucentStatus 安卓windowTranslucentNavigation 然后安卓statusBarColor 安卓navigationBarColor 被忽略。

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.

我缺少对http://developer.android.com/training/material/theme.html#StatusBar?

推荐答案

安卓windowTranslucentStatus 的假的并置机器人:statusBarColor @android:彩色/透明

然后添加code:

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

如果你也想导航条是半透明的,集安卓navigationBarColor @android:彩色/透明并结合标志 View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION

If you also want 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 experimented on navigation bar but it will work.