Solution 1 :
You could use methods transitionToStart / transitionToEnd
on MotionLayout to perform animations from code. And therefore you can call this methods in onStart/onResume
Fragment or Activity methods for example.
https://developer.android.com/reference/androidx/constraintlayout/motion/widget/MotionLayout#transitionToEnd()
Example:
class MyFragment: Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Start animation programmatically after all views created
motion_layout.transitionToEnd()
}
}
Problem :
I’ve been watching motion animation layout videos and I’ve seen that the animation gets activated after a click or a swipe, how can I make the animation start when all the views have been created, like for example in a Hero Animation?
Comments
Comment posted by AgentP
I have’t tried it personally if it’s working after a click how about calling performClick() on a view after allviews created?
Comment posted by Andrey Solera
can you please add code examples on how to use the code please?