I'm trying to execute this code:
animationView.cancelAnimation();
animationView.setAnimation("empty.json");
animationView.setRepeatCount(LottieDrawable.INFINITE);
animationView.setScale(1);
animationView.playAnimation();
Unfortunatelly, the animation isn't shown if I include the line animationView.setScale(1);. Isn't it possible to change scale at runtime?
The XML File looks like that
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/aniMitte"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
app:layout_constraintBottom_toTopOf="@+id/lblCenterText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:lottie_autoPlay="true"
app:lottie_fileName="loading.json"
app:lottie_loop="true"
app:lottie_scale="2" />
@Philipp97714 This is most likely due to your ConstraintLayout constraints causing the view to remain a certain size. Try adjusting your constraints or as a test, try setting a different image drawable on the LottieAnimationView (it extends ImageView so you can use it like you would anything other ImageView).
If you can't figure it out, attach a sample project.
you should set your LottieAnimationView wrapcontent then setScale take effect
Most helpful comment
you should set your LottieAnimationView wrapcontent then setScale take effect