Lottie · Android

Lottie in Android

Add Lottie animated icons to your Android app using the official Airbnb Lottie library for Kotlin.

1

Add the Lottie dependency

Open your app-level build.gradle and add the Lottie dependency.

copy
dependencies {
    implementation 'com.airbnb.android:lottie:6.0.0'
}
2

Place the JSON file

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.

3

Add LottieAnimationView to your layout

Reference the animation file using app:lottie_rawRes in your XML layout.

copy
<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" />
4

Control the animation in Kotlin

Use the view reference to play, pause, or swap animations at runtime.

copy
val animationView = findViewById<LottieAnimationView>(R.id.lottieIcon)
animationView.setAnimation(R.raw.your_animation)
animationView.playAnimation()
// animationView.pauseAnimation()
// animationView.cancelAnimation()
Get your icons
Browse animated icons ready for Android.
Browse free icons →