设置AppBarLayout的高程时,ToolBar消失 [英] ToolBar disappears when setting elevation for AppBarLayout

查看:100
本文介绍了设置AppBarLayout的高程时,ToolBar消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AppBarLayout设置高度时,我的ToolBar消失.这是布局.

My ToolBar disappears when setting elevation for AppBarLayout. Here's the layout.

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="@dimen/appbar_height"
    app:elevation="0dp"
    android:background="@color/transparent">

    <android.support.v7.widget.Toolbar
        style="@style/ToolBarStyle"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:elevation="0dp"
        android:background="@drawable/backgorund_toolbar_tranluscent"
        android:minHeight="@dimen/abc_action_bar_default_height_material" />
</android.support.design.widget.AppBarLayout>

我为app:elevation尝试了0dp,0.1dp和4dp之类的值.这里发生了什么事?它是支持库错误吗?我正在使用24.0.0.

I have tried values like 0dp, 0.1dp and 4dp for app:elevation. What's happening here? Is it a support library bug? I'm using 24.0.0.

推荐答案

新更新:在Appcompat v24.0.0中,由于已弃用setElevation()和app:elevation,因此无法使用AppElevation()和app:elevation将海拔设置为AppBarLayout.

New Update: In Appcompat v24.0.0, you can not set elevation to AppBarLayout using setElevation() and app:elevation as these are deprecated.

您现在必须使用stateListAnimator属性来设置高程.

You have to use stateListAnimator property to set elevation now.

注意:在StateListAnimator中将持续时间设置为1ms,以避免在立面图中延迟.

Note: set duration to 1ms in StateListAnimator in order to avoid delay in Elevation Drawing.

AppBarat v24.0.0上的AppBarLayout高程更改被延迟

AppBarLayout elevation change is delayed on appCompat v24.0.0

这篇关于设置AppBarLayout的高程时,ToolBar消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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