or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

asset-management.mdcomposition-loading.mdconfiguration-performance.mddynamic-properties.mdindex.mdview-components.md
tile.json

tessl/maven-com-airbnb-android--lottie

Android library for rendering Adobe After Effects animations exported as JSON through Bodymovin with native performance and extensive customization options.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/com.airbnb.android/lottie@5.2.x

To install, run

npx @tessl/cli install tessl/maven-com-airbnb-android--lottie@5.2.0

index.mddocs/

Lottie Android

Lottie Android is a comprehensive mobile library that parses Adobe After Effects animations exported as JSON through Bodymovin and renders them natively on Android devices. It provides high-performance animation playback with extensive customization options, dynamic property control, and support for complex animations including shapes, transforms, gradients, and effects.

Package Information

  • Package Name: com.airbnb.android:lottie
  • Package Type: maven
  • Language: Java
  • Installation: implementation 'com.airbnb.android:lottie:5.2.0'

Core Imports

import com.airbnb.lottie.LottieAnimationView;
import com.airbnb.lottie.LottieDrawable;
import com.airbnb.lottie.LottieComposition;
import com.airbnb.lottie.LottieCompositionFactory;

Basic Usage

// In layout XML
<com.airbnb.lottie.LottieAnimationView
    android:id="@+id/animation_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:lottie_fileName="animation.json"
    app:lottie_loop="true"
    app:lottie_autoPlay="true" />

// In code
LottieAnimationView animationView = findViewById(R.id.animation_view);
animationView.setAnimation("loading.json");
animationView.playAnimation();

// Using LottieDrawable programmatically
LottieDrawable drawable = new LottieDrawable();
LottieCompositionFactory.fromAsset(context, "animation.json")
    .addListener(drawable::setComposition);
imageView.setImageDrawable(drawable);
drawable.playAnimation();

Architecture

Lottie Android is built around several key components:

  • View Integration: LottieAnimationView for direct layout usage with automatic lifecycle management
  • Drawable API: LottieDrawable for programmatic use in custom views and complex layouts
  • Composition Model: LottieComposition as immutable, cacheable animation data
  • Factory System: LottieCompositionFactory for async loading from various sources (assets, URLs, streams)
  • Dynamic Properties: KeyPath and LottieValueCallback system for runtime animation modification
  • Asset Management: Delegate pattern for custom image, font, and text handling
  • Performance Optimization: Hardware/software rendering modes and comprehensive caching

Capabilities

View Components

Primary UI components for displaying Lottie animations in Android layouts and custom views.

public class LottieAnimationView extends AppCompatImageView {
    public void setAnimation(String fileName);
    public void setAnimation(int rawResId);
    public void playAnimation();
    public void pauseAnimation();
    public void setProgress(float progress);
}

public class LottieDrawable extends Drawable implements Animatable {
    public void setComposition(LottieComposition composition);
    public void start();
    public void stop();
    public void setProgress(float progress);
}

View Components

Composition Loading

Factory methods and async operations for loading animations from various sources with caching support.

public class LottieCompositionFactory {
    public static LottieTask<LottieComposition> fromAsset(Context context, String fileName);
    public static LottieTask<LottieComposition> fromUrl(Context context, String url);
    public static LottieTask<LottieComposition> fromRawRes(Context context, int rawRes);
    public static LottieTask<LottieComposition> fromJsonString(String json, String cacheKey);
}

public class LottieComposition {
    public Rect getBounds();
    public float getDuration();
    public float getFrameRate();
    public List<Marker> getMarkers();
}

Composition Loading

Dynamic Properties

Runtime animation modification system using keypaths to target specific elements and properties.

public class KeyPath {
    public KeyPath(String... keys);
    public static final KeyPath COMPOSITION;
}

public class LottieValueCallback<T> {
    public LottieValueCallback(T staticValue);
    public T getValue(LottieFrameInfo<T> frameInfo);
    public void setValue(T value);
}

public interface LottieProperty {
    Integer COLOR = 1;
    Integer STROKE_COLOR = 2;
    Integer TRANSFORM_OPACITY = 3;
    Integer OPACITY = 4;
    PointF TRANSFORM_ANCHOR_POINT = new PointF();
    PointF TRANSFORM_POSITION = new PointF();
    Float TRANSFORM_POSITION_X = 15f;
    Float TRANSFORM_POSITION_Y = 16f;
    PointF ELLIPSE_SIZE = new PointF();
    PointF RECTANGLE_SIZE = new PointF();
    Float CORNER_RADIUS = 0f;
    ScaleXY TRANSFORM_SCALE = new ScaleXY();
}

Dynamic Properties

Asset Management

Delegate interfaces for handling custom image assets, fonts, and dynamic text replacement.

public interface ImageAssetDelegate {
    Bitmap fetchBitmap(LottieImageAsset asset);
}

public interface FontAssetDelegate {
    Typeface fetchFont(String fontFamily);
    String getFontPath(String fontFamily);
}

public class TextDelegate {
    public String getText(String layerName, String sourceText);
    public void setText(String layerName, String text);
}

Asset Management

Configuration and Performance

Global configuration, render mode settings, and performance optimization options.

public class Lottie {
    public static void initialize(LottieConfig config);
}

public class LottieConfig {
    public static class Builder {
        public Builder setNetworkFetcher(LottieNetworkFetcher fetcher);
        public Builder setNetworkCacheDir(File dir);
        public Builder setEnableSystraceMarkers(boolean enable);
        public LottieConfig build();
    }
}

public enum RenderMode {
    AUTOMATIC, HARDWARE, SOFTWARE;
    public boolean useSoftwareRendering(int sdkInt, boolean hasDashPattern, int numMasksAndMattes);
}

@IntDef({RESTART, REVERSE})
@Retention(RetentionPolicy.SOURCE)
public @interface RepeatMode {}

public static final int RESTART = ValueAnimator.RESTART;
public static final int REVERSE = ValueAnimator.REVERSE;

Configuration and Performance

Core Types

public interface LottieListener<T> {
    void onResult(T result);
}

public interface LottieOnCompositionLoadedListener {
    void onCompositionLoaded(LottieComposition composition);
}

public class LottieTask<T> {
    public LottieTask<T> addListener(LottieListener<T> listener);
    public LottieTask<T> addFailureListener(LottieListener<Throwable> listener);
    public LottieTask<T> removeListener(LottieListener<T> listener);
    public LottieTask<T> removeFailureListener(LottieListener<Throwable> listener);
}

public class LottieResult<V> {
    public V getValue();
    public Throwable getException();
}

public interface Cancellable {
    void cancel();
}

public class LottieFrameInfo<T> {
    public float getStartFrame();
    public float getEndFrame();
    public T getStartValue();
    public T getEndValue();
    public float getLinearKeyframeProgress();
    public float getInterpolatedKeyframeProgress();
    public float getOverallProgress();
}

public class ScaleXY {
    public ScaleXY(float scaleX, float scaleY);
    public float getScaleX();
    public float getScaleY();
}

public class LottieImageAsset {
    public String getId();
    public int getWidth();
    public int getHeight();
    public String getFileName();
    public Bitmap getBitmap();
}

public class Marker {
    public String getName();
    public float getStartFrame();
    public float getDurationFrames();
    public float getDurationAsSeconds();
}