Using Lottie for engaging Android animations
Android interfaces often need motion to explain progress, confirm an action or guide attention. Lottie renders animation data exported from design tools as vector-based motion inside an Android app, so a loading indicator or success celebration does not have to be a large video file.
A useful implementation starts with a small JSON asset, connects it to a view, and then adds playback control for the app's states. This workflow suits beginner projects and more advanced apps built with XML layouts or Jetpack Compose.
Prepare the animation asset
Lottie animations are normally created in Adobe After Effects and exported with the Bodymovin plugin. The export produces JSON containing keyframes, shapes, colours and timing. You can also obtain JSON from a designer, but each file should be checked in a browser or the Lottie preview tool before it reaches the app.
Keep the composition dimensions aligned with its Android destination and give layers meaningful names. If the export contains bitmap images, export those assets as well and retain their relative folder structure; the app must be able to locate them when the JSON loads.
Add Lottie to the Android project
Add the Android dependency to the app-level build.gradle.kts file. This library provides the animation view, parser and playback controls used in the following examples:
dependencies {
implementation("com.airbnb.android:lottie:6.6.7")
}
Place the exported file under app/src/main/res/raw using a lowercase name such as loading_animation.json. Check the library's current stable release and its Android requirements when updating an existing project. For broader Android examples, the site's Android animation tutorials provide a useful path through layouts, UI components and project-based code.
Load an animation in a layout
Declare a LottieAnimationView inside the relevant layout and point lottie_rawRes at the raw resource. The autoPlay and loop attributes are convenient for a lightweight loading state:
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/loadingAnimation"
android:layout_width="match_parent"
android:layout_height="180dp"
android:scaleType="fitCenter"
app:lottie_rawRes="@raw/loading_animation"
app:lottie_autoPlay="true"
app:lottie_loop="true" />
Give the view a stable ID and size it for the space available on the screen. For a decorative animation, mark it as unimportant for accessibility; when the motion conveys status, pair it with text that remains visible to screen-reader users.
Control playback with Kotlin
A LottieAnimationView can be located with findViewById, or accessed through view binding when that feature is enabled. The same view can load different assets and move between idle, playing, paused and completed states without recreating the surrounding screen.
val animation = findViewById<LottieAnimationView>(R.id.loadingAnimation)
animation.setAnimation(R.raw.success_animation)
animation.playAnimation()
animation.pauseAnimation()
animation.cancelAnimation()
animation.progress = 0.75f
animation.speed = 1.25f
Use setAnimation only when the asset changes, and call playAnimation when the associated app state becomes active. If the JSON includes images, configure the matching assets folder with setImageAssetsFolder and handle loading failures with a listener instead of allowing an empty screen.
Use Lottie with Jetpack Compose
Compose projects use the companion lottie-compose artifact. Remember the composition, animate its progress and pass both values to LottieAnimation:
implementation("com.airbnb.android:lottie-compose:6.6.7")
val composition by rememberLottieComposition(
LottieCompositionSpec.RawRes(R.raw.loading_animation)
)
val progress by animateLottieCompositionAsState(
composition = composition,
iterations = LottieConstants.IterateForever
)
LottieAnimation(
composition = composition,
progress = { progress },
modifier = Modifier.size(180.dp)
)
For an event that should play once, switch isPlaying from false to true when the event occurs. Keep looping animations reserved for genuine ongoing work, since continuous rendering consumes resources even when the underlying network request has finished.
Design animations for Australian apps
Motion should clarify a local user journey rather than decorate every screen. A transport or ticketing app used by Sydney commuters can show a brief vehicle or ticket animation while a request completes, but it should not hide the route, fare or service update behind the motion.
Australian retail and hospitality apps also need clear financial context. A Melbourne café pre-order screen can use a small cup animation while an order is sent, while checkout copy continues to show prices in Australian dollars with GST included. The animation must never imply that payment succeeded before the backend confirms it.
Regional connections across Australia make restrained assets especially valuable. Compress the JSON, remove unused layers and avoid oversized raster images so the animation remains usable over variable mobile data. Seasonal campaigns can add suitable artwork for Australia Day or Easter, but these localised versions should not increase the size of the default asset downloaded by every customer.
Compare Lottie with other animation options
The right technique depends on whether the motion needs app state, complex artwork or simple platform behaviour. Native transitions and animated vector resources are often lighter, while GIFs and video are convenient when the source cannot be represented as keyframes.
| Approach | Best suited to | Strengths | Main trade-off |
|---|---|---|---|
| Lottie JSON | Stateful and multi-part motion | Rich vector animation and code control | Requires careful export and asset preparation |
| Animated vector resources | Small icons and simple effects | Small size and direct framework support | Limited timelines and interaction |
| GIF or video | Pre-rendered visual sequences | Easy to import and visually predictable | Larger files and weaker state control |
| Native transitions | Standard screen changes | Smooth with platform behaviour | Not suitable for custom illustrated stories |
Lottie is most valuable when animation carries meaning, such as progress, feedback or onboarding, and the app can control when it starts and stops. For these cases, a compact JSON asset offers more flexibility than a fixed GIF while retaining the efficiency of vector rendering.