CollapsingToolbarLayout过度滚动并卡住

我正在通过以下Scrollflags实现CollapsingToolbarLayout

app:layout_scrollflags="scroll|enterAlways|exitUntilCollapsed|snap"

,当我向上滚动时,滚动过度并卡住。 仅当您使用扩展的应用栏向上滚动时,它才会发生。我认为将enterAlwaysexitUntilCollapsed结合使用会导致这种情况。如何解决此问题?

这是我的xml布局

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

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar"
        android:layout_width="match_parent"
        android:layout_height="@dimen/app_bar_height"
        android:fitsSystemWindows="true"
        android:theme="@style/Apptheme.AppBarOverlay">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:id="@+id/toolbar_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:expandedTitleMarginTop="0dp"
            app:contentScrim="?attr/colorPrimary"
            app:layout_scrollflags="scroll|enterAlways|exitUntilCollapsed|snap"
            app:toolbarId="@+id/toolbar">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:minHeight="?attr/actionBarSize"
                android:layout_gravity="top"
                app:layout_collapseMode="pin"
                app:title="App Title"
                app:popuptheme="@style/Apptheme.PopupOverlay">

            </androidx.appcompat.widget.Toolbar>

        </com.google.android.material.appbar.CollapsingToolbarLayout>
    </com.google.android.material.appbar.AppBarLayout>

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

    <com.google.android.material.floatingactionbutton.FloatingactionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/fab_margin"
        app:layout_anchor="@id/app_bar"
        app:layout_anchorGravity="bottom|end"
        app:srcCompat="@android:drawable/ic_dialog_email" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

预先感谢

CollapsingToolbarLayout过度滚动并卡住

zhoubingpei 回答:CollapsingToolbarLayout过度滚动并卡住

您应该尝试在this.state = { character: [],typedValue: '' }; 中不使用render() { const {character,typedValue} = this.state let filter = character.filter(char => char.name.includes(typedValue)); // ... } 属性,并从snap中删除scrollFlags,因为在您的情况下没有必要。

请尝试这个。我的应用程序中有折叠工具栏,可以正常工作。

min__height
本文链接:https://www.f2er.com/3160165.html

大家都在问