Android liftOnScroll不使用NestedScrollView

Android liftOnScroll不使用NestedScrollView,android,material-design,android-toolbar,material-components-android,Android,Material Design,Android Toolbar,Material Components Android,当我将app:liftOnScroll=“true”设置为我的AppBarLayout,然后启动应用程序时,我看不到任何阴影,向下或向上滚动都不起作用 我的布局: <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/

当我将app:liftOnScroll=“true”设置为我的AppBarLayout,然后启动应用程序时,我看不到任何阴影,向下或向上滚动都不起作用

我的布局:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <!--.....................................................regular-->
    <com.google.android.material.appbar.AppBarLayout
        app:liftOnScroll="true"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.Catalog.AppBarLayout"
        android:id="@+id/toolbar_regular"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <com.google.android.material.appbar.MaterialToolbar
            android:id="@+id/topAppBar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:title="Regular top app bar"
            app:menu="@menu/menu_with_icons"
            app:navigationIcon="@drawable/ic_drawer_white"
            />
    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        android:id="@+id/nested_scroll_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#f5f5f5"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <include layout="@layout/top_appbar_filler_text_view" />

    </androidx.core.widget.NestedScrollView>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:layout_gravity="bottom|end"
        android:id="@+id/fab_add"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/spacing_middle"
        android:layout_marginLeft="@dimen/spacing_smlarge"
        android:layout_marginRight="@dimen/spacing_smlarge"
        android:layout_marginTop="@dimen/spacing_middle"
        android:clickable="true"
        android:tint="@android:color/white"
        app:backgroundTint="@android:color/black"
        app:fabSize="normal"
        app:tint="@color/white"
        app:rippleColor="@android:color/white"
        app:srcCompat="@drawable/ic_baseline_edit_24"
        android:focusable="true"
        android:contentDescription="@string/fab_description" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
参考文件: 将滚动行为应用于顶部应用程序栏 它应该会增加高度,并让内容在后面滚动。

很难注意到。 尝试将应用程序栏和主背景设置为白色,您将看到阴影

implementation 'com.google.android.material:material:1.3.0-beta01'