In this quickstart you will clone theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/lottie-kt-test/llms.txt
Use this file to discover all available pages before exploring further.
lottie-kt-test repository, open it in Android Studio, and deploy it to a device or emulator — all in under five minutes. Once the app is running you will see a looping Lottie animation fill the screen, and a single tap of the Change button will swap it for a second animation, giving you a hands-on feel for how runtime animation switching works with the Airbnb Lottie Android library.
Prerequisites — make sure you have the following before you begin:
- Android Studio Hedgehog (2023.1.1) or later — earlier versions may not support all Gradle features used in this project.
- Android SDK API 24 or higher — the app sets
minSdk = 24, so your SDK Manager must have at least API 24 installed. - A physical Android device or an AVD emulator — any device or emulator running Android 7.0 (Nougat) or above will work.
Steps
Clone the Repository
Open a terminal and clone the project from GitHub:This creates a
lottie-kt-test directory containing the full Android project, including the wh.json and logo2.json Lottie animation files pre-placed in app/src/main/assets/.Open in Android Studio
Launch Android Studio, then choose File → Open from the menu bar. Navigate to the
lottie-kt-test folder you just cloned and click OK.Gradle will sync the project automatically. Wait for the sync to complete — the status bar at the bottom of Android Studio will show “Gradle sync finished” when it is done. If prompted to update the Gradle plugin, you can safely dismiss the notification for this demo.Run the App
Select your connected device or running emulator in the toolbar target dropdown, then click the Run ▶ button (or press
Shift + F10).Android Studio will build and install the app with the application ID com.srm.lottiee. After a few seconds the app will launch and you will see the first Lottie animation (wh.json) playing in a loop against the dark #1A1A1A background.Toggle Between Animations
Tap the Change button at the top of the screen. The app immediately resets the animation frame to
0, loads logo2.json, and starts playing it. Tap Change again to switch back to wh.json. You can toggle as many times as you like — the switch is instantaneous and requires no restart.Key Code
Kotlin — Loading, Playing, and Switching Animations
The heart of the demo lives inMainActivity.kt. After binding the views, the code loads the first animation, sets its playback speed, attaches an ImageAssetDelegate, and wires the button to perform the toggle:
MainActivity.kt
setAnimation("wh.json")— resolves the file name against theassetsfolder automatically.speed = 2.0f— doubles the playback rate of the animation.setImageAssetDelegate— intercepts every image layer and returns a customBitmap; here it substitutesR.drawable.logofor whatever bitmap was bundled in the JSON.frame = 0— resets playback to the first frame before callingplayAnimation()so the new animation always starts from the beginning.
XML — Declaring LottieAnimationView in the Layout
TheLottieAnimationView is declared in activity_main.xml inside a LinearLayout. The Lottie-specific XML attributes configure looping and auto-play entirely at the layout level:
activity_main.xml
lottie_autoPlay="true"— starts playback as soon as the view is laid out, before any Kotlin code runs.lottie_loop="true"— keeps the animation looping indefinitely.lottie_repeatMode="restart"— jumps back to frame 0 at the end of each cycle rather than reversing.