Lottie With Jetpack Compose

Maria Luíza
Kt. Academy
Published in
3 min readSep 15, 2023

--

Hello, fantastic person on the internet! I hope you’re doing well.

I love to incorporate animation into components and screens. It is a fantastic way to make your app more engaging and beautiful.

Lottie, developed by Airbnb, and Jetpack Compose, the declarative UI toolkit from Google, have joined forces to simplify and enhance the animation experience for Android developers.

Lottie

Understanding Lottie in Compose is a valuable skill set to have in your toolkit.

Lottie is a declarative UI toolkit from Google that simplifies and enhances the animation experience for developers.

Implementation

First things first, we need to implement the Lottie library in our dependencies, within the gradle(Module:app):

Animation

There are several ways to incorporate…

The first method involves obtaining animations from the Lottie website.

Alternatively, you can utilize a plugin in Figma to create your own resources.

I am going to use an animation from the Lottie website:

Choose json file to download

This will generate a JSON file that you can reference in your code.

Create a package resource into your code, name this to raw, and paste the download file.

image showing the created package

Calling

Navigate to your main activity and create a variable for calling the JSON file:

Now, let’s create the progress parameter:

Let’s call the LottieAnimation to display the animation:

It’s as simple as that; you can animate icons, screens, buttons, and any image you want for your app.

Conclusion

Lottie, along with other Jetpack Compose tools such as Canvas and the Animation library from Material 3, empowers you to develop stunning UIs for your app.

All the code and examples it is in this repository.

Happy coding ❤

Please let me know what you think in the comments…

Connect with me 👇

Kt. Academy blog

--

--

I'm an Android developer (She/Her). Feel free to ask me anything about the Android world, learning Kotlin/Java & a bit of Dart.