Android appbarlayout高程显示在状态栏中 [英] Android appbarlayout elevation appears in status bar

查看:525
本文介绍了Android appbarlayout高程显示在状态栏中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何摆脱状态栏中的海拔高度?如果我在AppbarLayout中将app:elevation设置为0dp,则海拔不再显示在状态栏中,也不在AppbarLayout下方。

How do I get rid of the elevation in the status bar? If I set in AppbarLayout the app:elevation to 0dp the elevation doesn't appear anymore in status bar but also not below the AppbarLayout.

如何获取海拔在AppbarLayout下?

How do I just get the elevation under the AppbarLayout?

下面是我的意思的屏幕截图: puush链接,请注意状态栏中的阴影:(

Here's a screenshot of what I mean: puush link, notice the shadow in the status bar :(

谢谢!

推荐答案

我们担心的是状态栏为透明时可见的 AppBarLayout 的阴影。不透明的状态栏并非始终可用。这在Lollipop&

Our concern is about shadow of AppBarLayout visible when status bar is transparent. Having an opaque status bar is not viable at all times. This happens on Lollipop & above only because of dynamic shadow rendering. On Marshmallow the wrong shadow looks even worse.

最佳解决方案

您的根布局始终都应具有 android:fitsSystemWindows = true ,否则您的UI不会在状态栏后面绘制。

Your root layout should have android:fitsSystemWindows="true" at all times, otherwise your UI will not draw behind status bar.

现在将 AppBarLayout 包裹在另一个<$ c中$ c> CoordinatorLayout ,其中具有 android:fitsSystemWindows = false 。这样可以防止阴影溢出到状态栏中

Now wrap the AppBarLayout inside another CoordinatorLayout which has android:fitsSystemWindows="false". This will prevent the shadow from overflowing into statusbar

其他解决方法(不推荐)

在您的样式中删除statusBarColor:

In your Style remove the statusBarColor:

<item name="android:statusBarColor">@android:color/transparent</item> 

所以您的主题将是:

<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>

也可以在appbarlayout上简单地设置app:elevation = 0dp,但这会删除底部的阴影也一样。

这篇关于Android appbarlayout高程显示在状态栏中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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