Open In App
Related Articles

How to add Lottie Animation in an Android app

Like Article
Save Article
Report issue

This article is about enhancing the User Interface of the mobile application by adding Lottie animation files into our mobile app. The Lottie animations are free to use vector animation files. These animation files can be found at the official site here. Many famous applications use this such as Uber, Netflix, Google, Airbnb, Shopify, etc.
Below is an example of Lottie Animation:

Dynamic properties of Lottie Animations

  • These can be used to give the app a theme.
  • These can be added in response to any event such as error, success, etc.
  • These can be animated to a single part of the animation in response to any user.
  • Responding to view sizes or other values not known at design time.

Advantages of Lottie

  • It supports a larger set of After Effects features.
  • Developers can set the progress to add the animation to a gesture, event, etc.
  • Masks are anti-aliased.
  • Developers have the freedom to change speed and color of a specific part of an animations dynamically.

Step 1: Add this dependency into the App level gradle module of the project and then sync the gradle with the project. This library enables us to use Lottie’s animations: 


// Lottie dependency
def lottieVersion = "3.4.0" implementation "$lottieVersion"


Step 2: Choose any animation from here and download the JSON file of animation 

Downloading the JSON animation file

Step 3: Now include the XML code into the layout file where you want to show the animation. Here the file name for JSON file is assumed to be animation. Different methods through which Lottie can take JSON files

  • A JSON animation: src/main/res/raw 
  • A JSON file: src/main/assets 
  • A zip file: src/main/assets 

Below is the XML code: 




Step 4:(optional) Adding controls to animation: 

  • Adding custom progress: Here the initial and the final value for progress is customized.


// Custom animation speed or duration.
ValueAnimator animator
    = ValueAnimator.ofFloat(0f, 1f);
    .addUpdateListener(animation -> {




  • Adding Animation listener: Different listeners can be added with the lottie animations. 


// Declaring the animation view
LottieAnimationView animationView
    = findViewById(;
        (animation) -> {
            // Do something.
if (animationView.isAnimating()) {
    // Do something.




Last Updated : 06 Oct, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads