【问题标题】:liftOnScroll not working with NestedScrollViewliftOnScroll 不适用于 NestedScrollView
【发布时间】:2021-04-21 05:19:20
【问题描述】:

当我将 app:liftOnScroll="true" 设置为我的 AppBarLayout,然后启动应用程序时,我看不到任何阴影,并且向下或向上滚动也不起作用。 p>

我的布局:

<?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'

参考文档: 将滚动行为应用到顶部应用栏 https://material.io/components/app-bars-top/android#regular-top-app-bar应该增加高度并让内容在其后面滚动。

【问题讨论】:

    标签: android material-design android-toolbar material-components-android


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      • 2015-10-22
      • 1970-01-01
      • 1970-01-01
      • 2018-08-27
      • 1970-01-01
      • 2018-03-20
      相关资源
      最近更新 更多