Issue
I am facing a problem using Lottie files as an animation. I can not set loop number while after loading it is looping continuously but I want to set fixed loop number.
Activity XML
<com.airbnb.lottie.LottieAnimationView
android:layout_centerInParent="true"
android:id="@+id/animation_view_1"
android:layout_width="150dp"
android:layout_height="150dp"
app:lottie_autoPlay="true"
app:lottie_loop="true" />
Activity Java
animationView.setVisibility(View.VISIBLE);
animationView.setAnimation(fileName);
animationView.loop(true);
animationView.playAnimation();
Solution
As animationView.loop(true);
is deprecated.
In addition to Phan Van Linh asnwer,
Using .xml file
<com.airbnb.lottie.LottieAnimationView
...
app:lottie_repeatCount="3"
/>
Using java you can use
animationView.setRepeatCount(LottieDrawable.INFINITE);// for Infinite loops
OR
animationView.setRepeatCount(3);// for 3 loops
Answered By - Amin Pinjari
Answer Checked By - Marie Seifert (JavaFixing Admin)