I can programatically start an Animation with lottie in Kotlin but I am struggling to create an AnimationListener. How exactly do I do that?
First, I tried it with an if-statement via the animation_view.progress but that did not work.
textChanger.setOnClickListener{
animation_view.setAnimation("data.json")
animation_view.playAnimation()
animation_view.loop(false)
}
I would like it to detect when the animation has finished so I can e.g. make a Toast. Are there any good lottie documentations for Kotlin?
Thanks for the help, just starting out with Android and Kotlin.
You can check this.
Try using this code :
animation_view.addAnimatorListener(object:Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onAnimationEnd(animation: Animator?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onAnimationCancel(animation: Animator?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun onAnimationStart(animation: Animator?) {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}