I am in the process of writing an app and wanted to have a Lottie animation as my splash screen, since I am learning java as I code this app I made a test app to see how things would work. I found that almost any Lottie animation displays just as a still image and does not play/loop the animation. I followed the guide on LottieFiles website and also information that I found on other questions but I still did not manage to get the animation playing. The following is exactly what I have added:
Gradle dependency of my app:
dependencies {
implementation 'com.airbnb.android:lottie:3.6.1'
}
To my Layout XML:
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/splashlottie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_fileName="opening_book.json" //Even tried placing the file in raw and using app:lottie_rawRes="@raw/opening_book"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
In my activity:
LottieAnimationView splashscreen;
splashscreen = findViewById(R.id.splashlottie);
splashscreen.animate();
splashscreen.playAnimation();
I am not sure exactly what I am doing wrong as I even tried various different lottie animation files and by placing the same file under raw and assets. Could the API level be the cause of the animation not playing?