How To Know When A Lottie Animation Is Completed?
I have a fragment, here is the onCreateView method: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflat
Solution 1:
This code works for me:
mAddedToCartAnimation.addAnimatorListener(newAnimator.AnimatorListener() {
@OverridepublicvoidonAnimationStart(Animator animation) {
Log.e("Animation:","start");
}
@OverridepublicvoidonAnimationEnd(Animator animation) {
Log.e("Animation:","end");
//Your code for remove the fragmenttry {
getActivity().getSupportFragmentManager()
.beginTransaction().remove(this).commit();
} catch(Exception ex) {
ex.toString();
}
}
@OverridepublicvoidonAnimationCancel(Animator animation) {
Log.e("Animation:","cancel");
}
@OverridepublicvoidonAnimationRepeat(Animator animation) {
Log.e("Animation:","repeat");
}
});
I hope this solve your problem :)
Solution 2:
Kotlin Code for animation complete :
successAnimation.addAnimatorListener(object : Animator.AnimatorListener{
overridefunonAnimationRepeat(animation: Animator?) {
}
overridefunonAnimationEnd(animation: Animator?) {
//Add your code here for animation end
}
overridefunonAnimationCancel(animation: Animator?) {
}
overridefunonAnimationStart(animation: Animator?) {
}
})
Post a Comment for "How To Know When A Lottie Animation Is Completed?"