when i called setComposition ,the LottieAnimationView will display the first frame of the animation,but when the animation finished, i can not reset the animation to first frame except i call animation.reverse(),but this will lead to the animation reverse play.
so ,is there some way to reset the animation to the first frame
Will this work for you? set progress to 0 should show you the first frame.
animationView.addAnimatorListener(new AnimatorListenerAdapter() {
@Override public void onAnimationEnd(Animator animation) {
animationView.setProgress(0);
}
});
@shuixingge if @howard0020's suggestion doesn't work for you, reopen this.
Doesn't work for me
@samy-baili What version of Lottie? And can you post your code?
Not working for me either. version 2.5.4. Code:
Completable.fromEmitter {
animationView.removeAllAnimatorListeners()
animationView.addAnimatorListener(object : Animator.AnimatorListener {
override fun onAnimationRepeat(animation: Animator?) {
}
override fun onAnimationCancel(animation: Animator?) {
}
override fun onAnimationStart(animation: Animator?) {
}
override fun onAnimationEnd(animation: Animator?) {
it.onCompleted()
}
})
animationView.playAnimation()
})
When I reach the code for the second time, the Completable directly emits onComplete.
For me there's not setProgress function on LottieView.
The one that worked for me was reset.
<LottieView ref={x => this.animation = x} />
this.animation.reset();
@iuliuvisovan You're using React Native. This thread is for Android.
Oh well. This is awkward.
I can just hope other RN devs will be as distracted as I was and find this helpful. 馃拑
Why are you marking these as closed when you haven't posted the solution yet??? how to reset animation view so that a different animation can be played in the same container???? don't mark it closed till it is not closed properly
i am having same problem how to set first frame when animation is ended??
@ganeshpadhayay @PrinceVergil https://github.com/airbnb/lottie-android/issues/314#issuecomment-304468565
Most helpful comment
Will this work for you? set progress to 0 should show you the first frame.