I have a motion layout and I want to when animation ended, Start another activity. So I have two problems:
I create this Description file for motion layout:
<Transition
android:id="@+id/starttoend"
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="800" />
<Transition
android:id="@+id/deley"
motion:constraintSetEnd="@+id/deleyLayout"
motion:constraintSetStart="@+id/end"
motion:duration="800" />
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/_80sdp"
android:rotation="120"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:rotation="0"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/deleyLayout">
<Constraint
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
This code animates an image view and then wait for 800ms. My problem is when I set motion_layout.transitionToEnd()
to activity, Animation not starting.
When I use motion:autoTransition="animateToEnd" attribute in Transition Tag, And set a listener to motion layout for use Intent, Activity will be black and not show anything and then launch intent activity. And in my Log I have two "Done":
motion_splash.addTransitionListener(object : MotionLayout.TransitionListener { override fun onTransitionStarted(p0: MotionLayout?, p1: Int, p2: Int) { } override fun onTransitionChange( p0: MotionLayout?, p1: Int, p2: Int, p3: Float ) { } override fun onTransitionCompleted(p0: MotionLayout?, p1: Int) { Log.i("completed" , "Done") startActivity(Intent(this@SplashScreenActivity, MainActivity::class.java)) finish() } override fun onTransitionTrigger( p0: MotionLayout?, p1: Int, p2: Boolean, p3: Float) { } })
Can you help me, please?!