Я сейчас изучаю motionlayout. Я создал небольшое приложение, в котором изображение в центре вращается в течение 5 секунд. Атрибуты onClick и onSwipe отлично работают на устройстве, но с autotransition = animateToEnd ничего не происходит, когда я запускаю приложение на устройстве. В основном я хочу, чтобы мой переход происходил автоматически при запуске действия. Вот мой файл макета движения:
<?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>
Вот мой 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>
Если есть альтернативный способ запустить переход с макетом движения, сообщите об этом. ** Для запуска приложения, которое я использовал для создания отладочного apk, а затем запускал его на моем устройстве.