I currently learning motionlayout. I created a small app in which the image in the center rotates for 5 seconds. onClick and onSwipe attributes are working fine on the device but with autotransition = animateToEnd nothing is happening when I run the app on the device. Basically I want my transition to happen automatically as the activity starts. Here is my motion layout file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/activity_main_scene">
<ImageView
android:id="@+id/back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="TODO"
android:src="@drawable/background" />
<ImageView
android:id="@+id/moon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/ic_moon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.motion.widget.MotionLayout>
Here is my motionScene:
<?xml version="1.0" encoding="utf-8"?>
<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="5000"
motion:autoTransition="animateToEnd">
<KeyFrameSet>
<KeyCycle
motion:motionTarget="@+id/moon"
motion:framePosition="0"
motion:wavePeriod="2"
motion:waveShape="sawtooth"
android:rotation="180"
motion:waveOffset="0" />
</KeyFrameSet>
</Transition>
<ConstraintSet android:id="@+id/start">
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
</ConstraintSet>
</MotionScene>
If there is any alternative way to run transition with motion layout please do tell. **For running the app I used to create debug apk and then run it on my device.