【问题标题】:How to set layoutTransition to animate correctly when item is removed from recycle view从回收视图中删除项目时如何设置 layoutTransition 以正确设置动画
【发布时间】:2020-10-27 13:27:55
【问题描述】:

我希望在从列表中删除项目之后发生过渡,但是当我删除项目时,过渡发生得更早,并且它涵盖了其他项目,如下面的 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)

但没有任何变化,总是相同的行为

【问题讨论】:

    标签: android kotlin android-recyclerview layouttransition


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-23
      • 2020-10-11
      • 2021-12-02
      相关资源
      最近更新 更多