Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tutosrive/lottie-kt-test/llms.txt
Use this file to discover all available pages before exploring further.
LottieAnimationView is the main Lottie rendering widget from the Airbnb Lottie Android library (version 6.7.1). It extends ImageView and handles JSON animation parsing, frame scheduling, and optional image-asset interception. This page covers every property, method, and XML attribute that this demo uses, drawn directly from MainActivity.kt and activity_main.xml.
Kotlin API
The following methods and properties are called on theLottieAnimationView instance (lottieView) inside MainActivity.onCreate().
Loads a Lottie JSON animation file from the app’s The demo switches between
assets/ folder. The file is parsed asynchronously and cached. Call this before playAnimation()."wh.json" and "logo2.json" each time the Change button is pressed.Starts or restarts the animation from the current frame position. If the animation is already playing it restarts from whatever frame is currently set.This is called once during initial setup and again inside the button’s
OnClickListener after the animation file and frame are updated.Controls the playback speed multiplier. A value of
1.0f is normal speed; values above 1.0f are faster, and negative values play the animation in reverse.Value used in this project: 2.0f (double speed).Gets or sets the current frame position of the animation. Setting this to In the demo this is set to
0 resets playback to the very first frame, ensuring a clean restart when switching animations.0 immediately before playAnimation() is called inside the button click listener.Registers a callback that is invoked whenever the Lottie renderer needs to load an image asset referenced inside the JSON file. Return a
Bitmap from the callback to substitute your own drawable. Return null to fall back to default behaviour.See the ImageAssetDelegate section below for the exact code used in this demo.XML Attributes
The following attributes are set directly on the<com.airbnb.lottie.LottieAnimationView> element in activity_main.xml. They configure the view declaratively without any Kotlin code.
When
true, the animation begins playing as soon as the view is attached to the window. This is equivalent to calling playAnimation() in onCreate().Value used: trueWhen
true, the animation repeats indefinitely after it reaches the last frame (or first frame in reverse mode). When false, the animation stops after one full cycle.Value used: trueControls the direction of each repeat cycle.
Value used:
| Value | Behaviour |
|---|---|
restart | Jumps back to frame 0 and plays forward again |
reverse | Plays backward from the last frame to the first frame |
restartImageAssetDelegate
When a Lottie JSON file references external image assets, theImageAssetDelegate interface lets you intercept each image load and return a custom Bitmap. In this demo the delegate always returns the logo.webp drawable regardless of which image the JSON requests.
The delegate is set as a SAM (Single Abstract Method) lambda directly in MainActivity.kt:
image
The image parameter is an LottieImageAsset object that describes the asset the renderer is asking for (its id, width, height, file name, and directory path as declared in the JSON). In this demo the parameter is received but not inspected — every request is answered with R.drawable.logo.
Return value
A Bitmap instance. The Lottie renderer uses this bitmap in place of the image asset declared in the JSON. Returning null falls back to the default file-based loading behaviour.
This page covers only the subset of the API used in this demo. For the complete
LottieAnimationView API surface — including cancelAnimation(), pauseAnimation(), addAnimatorListener(), composition listeners, and dynamic property callbacks — see the official Airbnb Lottie Android documentation.