完全透明状态栏和导航栏上的棒棒糖 [英] completely transparent status bar and navigation bar on lollipop

查看:334
本文介绍了完全透明状态栏和导航栏上的棒棒糖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个机器人发射。我想实现一个完全透明的状态栏和导航栏,这里是我的主题xml文件。

I'm trying to make an android launcher. I want to achieve a completely transparent status bar and navigation bar, here is my theme xml file.

<resources>
    <style name="Theme" parent="android:Theme.Material.Wallpaper.NoTitleBar">
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:navigationBarColor">@android:color/transparent</item>
        <item name="android:windowTranslucentStatus">false</item>
        <item name="android:windowTranslucentNavigation">false</item>
    </style>
</resources>

在最后两个项目不工作,还有棒棒糖上了一层阴影。

the last two items don't work, there is still a shadow on lollipop.

这是什么样子(注意,实际上是在状态栏和导航栏阴影):

This is what it looks like(note there is actually a shadow on status bar and navigation bar):

我想实现(新发射):

如何让状态栏和导航栏中的透明,而不是透明?

how to make the status bar and navigation bar "transparent" instead of "translucent"?

推荐答案

您可以编程实现对奇巧,之后通过设置该窗口标记相同的效果

Update

You can achieve the same effect programatically on KitKat and afterwards by setting this Window flag

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            Window w = getWindow(); // in Activity's onCreate() for instance
            w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
        }

如果您设置背景资源(如颜色或图片的)到你的布局,你会看到下面的状态栏的颜色或图片。

If you set a background resource (like a color or a picture) to your layout, you will see the color or picture "below" the status bar.

<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/primary_dark</item>


原来的答案

看起来这应该是,而不是


Original Answer

It looks like it should be true and not false

<resources>
    <style name="Theme" parent="android:Theme.Material.Wallpaper.NoTitleBar">
        <item name="android:statusBarColor">@android:color/transparent</item>
        <item name="android:navigationBarColor">@android:color/transparent</item>
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowTranslucentNavigation">true</item>
    </style>
</resources>

另外,你的透明活动/容器布局需要此属性:

Also, your transparent activity / container layout needs this property set:

android:fitsSystemWindows="true"

来源

这篇关于完全透明状态栏和导航栏上的棒棒糖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆