I have this view:
<androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/expandableModes"
android:layout_width="200dp"
android:layout_height="200dp"
android:paddingBottom="5dp"
app:layoutDescription="@xml/journey_motion"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/guidelineLeft"
app:layout_constraintTop_toBottomOf="@id/travelModeText">
....
</androidx.constraintlayout.motion.widget.MotionLayout>
And this motion layout:
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition
app:constraintSetEnd="@id/endExpand"
app:constraintSetStart="@id/startExpand"
app:duration="1000" />
<ConstraintSet android:id="@+id/startExpand">
<Constraint
android:id="@id/expandableModes"
android:layout_width="200dp"
android:layout_height="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/guidelineLeft"
app:layout_constraintTop_toBottomOf="@id/travelModeText" />
</ConstraintSet>
<ConstraintSet android:id="@+id/endExpand">
<Constraint
android:id="@id/expandableModes"
android:layout_width="10dp"
android:layout_height="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/guidelineLeft"
app:layout_constraintTop_toBottomOf="@id/travelModeText" />
</ConstraintSet>
</MotionScene>
I execute it by code:
binding.expandableModes.transitionToEnd {
print("")
}
My animation is played but my view is not resized, what did I missed ?
You are trying to animate the motion layout itself. You can only animate direct children as described here: https://developer.android.com/training/constraint-layout/motionlayout
You need to create a children of the view and animate this.