Сложный MotionLayout в RecyclerView, как реализовать правильно?
Всем доброго дня.
Стоит следующая задача: по нажатию на элемент списка RecyclerView в этом элементе появляется новый список (тоже RV) и все остальные элементы анимированно сдвигаются вниз. При этом важно, чтобы этот список находился в CardView, который в свою очередь содержит нужный мне RV, который при нажатии на CardView меняет visibility с gone на visible и при появлении этого списка мой CardView растягивался бы на нужную высоту.
На данном этапе я добился того, чтобы мой CardView растягивается только до первого элемента списка RV, и делает это не плавно, а резко.. Скорее всего проблема кроется в том, что я использую MotionLayout, вложенный в другой MotionLayout, но я не знаю как по-другому изменять visibility моего RV, который находится внутри CardView Подскажите, как правильно реализовать данную конструкцию?
Вот мой xml с viewHolder'ом, который должен анимироваться:
<androidx.constraintlayout.motion.widget.MotionLayout 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="wrap_content"
app:layoutDescription="@xml/day_holder_scene">
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="360dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/constraintLayout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/day_view_holder"
app:layoutDescription="@xml/day_holder_xml_constraintlayout3_scene">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_subjects"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:paddingBottom="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/day_tv"
tools:visibility="visible" />
<TextView
android:id="@+id/day_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:fontFamily="@font/myriad_bold"
android:paddingTop="20dp"
android:paddingBottom="20dp"
android:text="TextView"
android:textSize="24sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/date_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:fontFamily="@font/myriad_bold"
android:text="TextView"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="@+id/day_tv"
app:layout_constraintStart_toEndOf="@+id/day_tv"
app:layout_constraintTop_toTopOf="@+id/day_tv" />
</androidx.constraintlayout.motion.widget.MotionLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.motion.widget.MotionLayout>
Вот мои сцены для MotionLayout:
<MotionScene
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="400">
<KeyFrameSet>
</KeyFrameSet>
<OnClick motion:clickAction="toggle" />
</Transition>
<ConstraintSet android:id="@+id/start">
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
</ConstraintSet>
</MotionScene>
<MotionScene
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="400">
<KeyFrameSet>
</KeyFrameSet>
<OnClick motion:targetId="@id/day_tv"
motion:clickAction="toggle" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/recycler_subjects"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:layout_marginEnd="8dp"
motion:layout_constraintTop_toBottomOf="@+id/day_tv"
android:layout_marginStart="8dp"
motion:layout_constraintStart_toStartOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="visible"
android:layout_marginEnd="8dp"
motion:layout_constraintTop_toBottomOf="@+id/day_tv"
android:layout_marginStart="8dp"
motion:layout_constraintStart_toStartOf="parent"
android:id="@+id/recycler_subjects"
motion:layout_constraintBottom_toBottomOf="parent" />
</ConstraintSet>
</MotionScene>

