Jetpack Compose Lottie Animations

Updated 31 May 2022


In this blog, we are going to learn about “Lottie Animation”. I’ll teach you how to use Lottie animations without using any layout XML tags in Android Jetpack Compose. We must declare Lottie animation in the XML element in order to use it in Android. However, in Jetpack Compose, we express animation in the @Composable method rather than creating XML tags.

Add Dependency

First, you must include the Lottie library at the app level Gradle file.

Create new directory

Now that you’ve successfully integrated the Lottie library, you’ll need to create a new directory under res called raw and add the Lottie animation file to it. You can get Lottie animations here:

The Lottie animation file is learn.json in the raw directory.

Lottie composble

Now you must define the following code in your activity’s jetpack compose using composble functions.

I’ve established a variable called lottieAnimation that will be in charge of animating the screen.

I built a new variable called isLottiePlaying and animationSpeed to make it speed and autoplay.

Speed up the LottieAnimation() method by passing these two variables.

Following the creation of the Lottie animation technique, we are now constructing the button to change the speed of the Lottie animation.
In the same composable function, add the following code. Basic Columns, Rows, Buttons, and Text are all editable.
Three buttons and text are defined here, with the first two controlling animation speed and the third controlling play/pause.



We learned about Lottie in jetpack compose in this blog. We learned how to use Android to build the Lottie animation and generate various types of effects.

Visit the link for additional information on the compose Lottie animation in Android.

Thanks for reading this blog. You can also check other blogs from here for more knowledge.

Always be ready for learning 🙂

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home