or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

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

0

# Lottie Android

1

2

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.

3

4

## Package Information

5

6

- **Package Name**: com.airbnb.android:lottie

7

- **Package Type**: maven

8

- **Language**: Java

9

- **Installation**: `implementation 'com.airbnb.android:lottie:5.2.0'`

10

11

## Core Imports

12

13

```java

14

import com.airbnb.lottie.LottieAnimationView;

15

import com.airbnb.lottie.LottieDrawable;

16

import com.airbnb.lottie.LottieComposition;

17

import com.airbnb.lottie.LottieCompositionFactory;

18

```

19

20

## Basic Usage

21

22

```java

23

// In layout XML

24

<com.airbnb.lottie.LottieAnimationView

25

android:id="@+id/animation_view"

26

android:layout_width="wrap_content"

27

android:layout_height="wrap_content"

28

app:lottie_fileName="animation.json"

29

app:lottie_loop="true"

30

app:lottie_autoPlay="true" />

31

32

// In code

33

LottieAnimationView animationView = findViewById(R.id.animation_view);

34

animationView.setAnimation("loading.json");

35

animationView.playAnimation();

36

37

// Using LottieDrawable programmatically

38

LottieDrawable drawable = new LottieDrawable();

39

LottieCompositionFactory.fromAsset(context, "animation.json")

40

.addListener(drawable::setComposition);

41

imageView.setImageDrawable(drawable);

42

drawable.playAnimation();

43

```

44

45

## Architecture

46

47

Lottie Android is built around several key components:

48

49

- **View Integration**: `LottieAnimationView` for direct layout usage with automatic lifecycle management

50

- **Drawable API**: `LottieDrawable` for programmatic use in custom views and complex layouts

51

- **Composition Model**: `LottieComposition` as immutable, cacheable animation data

52

- **Factory System**: `LottieCompositionFactory` for async loading from various sources (assets, URLs, streams)

53

- **Dynamic Properties**: `KeyPath` and `LottieValueCallback` system for runtime animation modification

54

- **Asset Management**: Delegate pattern for custom image, font, and text handling

55

- **Performance Optimization**: Hardware/software rendering modes and comprehensive caching

56

57

## Capabilities

58

59

### View Components

60

61

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

62

63

```java { .api }

64

public class LottieAnimationView extends AppCompatImageView {

65

public void setAnimation(String fileName);

66

public void setAnimation(int rawResId);

67

public void playAnimation();

68

public void pauseAnimation();

69

public void setProgress(float progress);

70

}

71

72

public class LottieDrawable extends Drawable implements Animatable {

73

public void setComposition(LottieComposition composition);

74

public void start();

75

public void stop();

76

public void setProgress(float progress);

77

}

78

```

79

80

[View Components](./view-components.md)

81

82

### Composition Loading

83

84

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

85

86

```java { .api }

87

public class LottieCompositionFactory {

88

public static LottieTask<LottieComposition> fromAsset(Context context, String fileName);

89

public static LottieTask<LottieComposition> fromUrl(Context context, String url);

90

public static LottieTask<LottieComposition> fromRawRes(Context context, int rawRes);

91

public static LottieTask<LottieComposition> fromJsonString(String json, String cacheKey);

92

}

93

94

public class LottieComposition {

95

public Rect getBounds();

96

public float getDuration();

97

public float getFrameRate();

98

public List<Marker> getMarkers();

99

}

100

```

101

102

[Composition Loading](./composition-loading.md)

103

104

### Dynamic Properties

105

106

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

107

108

```java { .api }

109

public class KeyPath {

110

public KeyPath(String... keys);

111

public static final KeyPath COMPOSITION;

112

}

113

114

public class LottieValueCallback<T> {

115

public LottieValueCallback(T staticValue);

116

public T getValue(LottieFrameInfo<T> frameInfo);

117

public void setValue(T value);

118

}

119

120

public interface LottieProperty {

121

Integer COLOR = 1;

122

Integer STROKE_COLOR = 2;

123

Integer TRANSFORM_OPACITY = 3;

124

Integer OPACITY = 4;

125

PointF TRANSFORM_ANCHOR_POINT = new PointF();

126

PointF TRANSFORM_POSITION = new PointF();

127

Float TRANSFORM_POSITION_X = 15f;

128

Float TRANSFORM_POSITION_Y = 16f;

129

PointF ELLIPSE_SIZE = new PointF();

130

PointF RECTANGLE_SIZE = new PointF();

131

Float CORNER_RADIUS = 0f;

132

ScaleXY TRANSFORM_SCALE = new ScaleXY();

133

}

134

```

135

136

[Dynamic Properties](./dynamic-properties.md)

137

138

### Asset Management

139

140

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

141

142

```java { .api }

143

public interface ImageAssetDelegate {

144

Bitmap fetchBitmap(LottieImageAsset asset);

145

}

146

147

public interface FontAssetDelegate {

148

Typeface fetchFont(String fontFamily);

149

String getFontPath(String fontFamily);

150

}

151

152

public class TextDelegate {

153

public String getText(String layerName, String sourceText);

154

public void setText(String layerName, String text);

155

}

156

```

157

158

[Asset Management](./asset-management.md)

159

160

### Configuration and Performance

161

162

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

163

164

```java { .api }

165

public class Lottie {

166

public static void initialize(LottieConfig config);

167

}

168

169

public class LottieConfig {

170

public static class Builder {

171

public Builder setNetworkFetcher(LottieNetworkFetcher fetcher);

172

public Builder setNetworkCacheDir(File dir);

173

public Builder setEnableSystraceMarkers(boolean enable);

174

public LottieConfig build();

175

}

176

}

177

178

public enum RenderMode {

179

AUTOMATIC, HARDWARE, SOFTWARE;

180

public boolean useSoftwareRendering(int sdkInt, boolean hasDashPattern, int numMasksAndMattes);

181

}

182

183

@IntDef({RESTART, REVERSE})

184

@Retention(RetentionPolicy.SOURCE)

185

public @interface RepeatMode {}

186

187

public static final int RESTART = ValueAnimator.RESTART;

188

public static final int REVERSE = ValueAnimator.REVERSE;

189

```

190

191

[Configuration and Performance](./configuration-performance.md)

192

193

## Core Types

194

195

```java { .api }

196

public interface LottieListener<T> {

197

void onResult(T result);

198

}

199

200

public interface LottieOnCompositionLoadedListener {

201

void onCompositionLoaded(LottieComposition composition);

202

}

203

204

public class LottieTask<T> {

205

public LottieTask<T> addListener(LottieListener<T> listener);

206

public LottieTask<T> addFailureListener(LottieListener<Throwable> listener);

207

public LottieTask<T> removeListener(LottieListener<T> listener);

208

public LottieTask<T> removeFailureListener(LottieListener<Throwable> listener);

209

}

210

211

public class LottieResult<V> {

212

public V getValue();

213

public Throwable getException();

214

}

215

216

public interface Cancellable {

217

void cancel();

218

}

219

220

public class LottieFrameInfo<T> {

221

public float getStartFrame();

222

public float getEndFrame();

223

public T getStartValue();

224

public T getEndValue();

225

public float getLinearKeyframeProgress();

226

public float getInterpolatedKeyframeProgress();

227

public float getOverallProgress();

228

}

229

230

public class ScaleXY {

231

public ScaleXY(float scaleX, float scaleY);

232

public float getScaleX();

233

public float getScaleY();

234

}

235

236

public class LottieImageAsset {

237

public String getId();

238

public int getWidth();

239

public int getHeight();

240

public String getFileName();

241

public Bitmap getBitmap();

242

}

243

244

public class Marker {

245

public String getName();

246

public float getStartFrame();

247

public float getDurationFrames();

248

public float getDurationAsSeconds();

249

}

250

```