Airbnb's Lottie library handles the rendering. Four steps: dependency, JSON file, XML view, done.
Open your app-level build.gradle and add this to your dependencies block.
dependencies {
implementation 'com.airbnb.android:lottie:6.0.0'
}Download your icon from Unicorn Icons and place the .json file in app/src/main/res/raw/. Create the folder if it doesn't exist.
Reference the animation with app:lottie_rawRes. The view autoplays and loops by default.
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/lottieIcon"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
app:lottie_rawRes="@raw/your_animation"
app:lottie_autoPlay="true"
app:lottie_loop="true"
app:lottie_speed="1.0" />Get the view by ID and call play, pause, or swap the animation file at runtime.
val animationView = findViewById<LottieAnimationView>(R.id.lottieIcon)
animationView.setAnimation(R.raw.your_animation)
animationView.playAnimation()
// animationView.pauseAnimation()
// animationView.cancelAnimation()Where does the JSON file go?
In app/src/main/res/raw/. The file name without the extension becomes the resource ID — so star.json becomes @raw/star.
Can I load Lottie from a URL?
Yes. Use animationView.setAnimationFromUrl(url) instead. Add INTERNET permission to your manifest.
How do I loop a set number of times?
Set animationView.repeatCount = 3 — plays 4 times total. Use LottieDrawable.INFINITE for endless looping.
Get your animated icons
Browse icons ready for Android — free to download.