从回收视图中删除项目时如何设置 layoutTransition 以正确设置动画

How to set layoutTransition to animate correctly when item is removed from recycle view

我希望在项目从列表中删除后发生转换,但是当我删除项目时,转换发生得更早并且它覆盖了其他项目,如下面的 GIF 所示。 我的第二个问题是,当我使用 layoutTransition 时,当创建片段时它会随着动画展开,如何在开始时避免这种情况。 我的布局是这样的:

<androidx.core.widget.NestedScrollView
  android:id="@+id/scroll_view"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:animateLayoutChanges="true"
  android:fillViewport="true" >

    <androidx.constraintlayout.widget.ConstraintLayout
     android:id="@+id/constraintlayout"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:animateLayoutChanges="true"
     >
        
          <androidx.recyclerview.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

在片段中:(Kotlin):

scroll_view.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
scroll_view.layoutTransition.setStartDelay(LayoutTransition.CHANGING,300)
constraintlayout.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
constraintlayout.layoutTransition.setStartDelay(LayoutTransition.CHANGING,300)

但没有任何变化,行为始终相同

我找到了使用自定义布局管理器解决问题的方法:D 我使用的布局管理器:https://github.com/BelooS/ChipsLayoutManager