Android recyclerview动画无法使用约束布局

时间:2018-03-28 05:17:24

标签: android android-recyclerview android-animation

我正在通过此链接应用recyclerview动画 enter-animation-using-recyclerview-and-layoutanimation

但唯一的变化是我的recyclerview是在约束布局中,当我设置高度为wrap_content或match_parent动画时,我需要将高度设置为0dp用于关联视图。

我的XML代码

<android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/ivBanner"
                android:layout_width="0dp"
                android:layout_height="200dp"
                android:scaleType="centerCrop"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:srcCompat="@drawable/ic_img" />


            <android.support.v7.widget.RecyclerView
                android:id="@+id/rvList"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                android:layoutAnimation="@anim/layout_animation_from_bottom"
                app:layout_constraintTop_toBottomOf="@id/ivBanner" />

 </android.support.constraint.ConstraintLayout>

在recyclerview android:layout_height="0dp"我设置为match_parent或wrap_content动画效果很好,所以layout_animation_from_bottom没有问题提前谢谢:)

0 个答案:

没有答案