Skip to main content

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 the LottieAnimationView instance (lottieView) inside MainActivity.onCreate().
setAnimation
fun setAnimation(assetName: String)
Loads a Lottie JSON animation file from the app’s assets/ folder. The file is parsed asynchronously and cached. Call this before playAnimation().
lottieView.setAnimation("wh.json")
The demo switches between "wh.json" and "logo2.json" each time the Change button is pressed.
playAnimation
fun playAnimation()
Starts or restarts the animation from the current frame position. If the animation is already playing it restarts from whatever frame is currently set.
lottieView.playAnimation()
This is called once during initial setup and again inside the button’s OnClickListener after the animation file and frame are updated.
speed
var speed: Float
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).
lottieView.speed = 2.0f
frame
var frame: Int
Gets or sets the current frame position of the animation. Setting this to 0 resets playback to the very first frame, ensuring a clean restart when switching animations.
lottieView.frame = 0
lottieView.playAnimation()
In the demo this is set to 0 immediately before playAnimation() is called inside the button click listener.
setImageAssetDelegate
fun setImageAssetDelegate(delegate: ImageAssetDelegate)
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.
app:lottie_autoPlay
Boolean
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: true
app:lottie_autoPlay="true"
app:lottie_loop
Boolean
When 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: true
app:lottie_loop="true"
app:lottie_repeatMode
String — "restart" | "reverse"
Controls the direction of each repeat cycle.
ValueBehaviour
restartJumps back to frame 0 and plays forward again
reversePlays backward from the last frame to the first frame
Value used: restart
app:lottie_repeatMode="restart"

ImageAssetDelegate

When a Lottie JSON file references external image assets, the ImageAssetDelegate 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:
lottieView.setImageAssetDelegate { image ->
    val drawableId: Int = R.drawable.logo

    BitmapFactory.decodeResource(
        resources,
        drawableId
    )
}
Lambda parameter — 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.

Build docs developers (and LLMs) love