Some Lottie animations reference external bitmap images alongside their vector and shape data. When the Lottie renderer encounters one of these image references it calls through to anDocumentation 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.
ImageAssetDelegate to obtain the actual Bitmap to draw. By supplying your own delegate you can intercept every image request and return any bitmap you choose — a local drawable, a user-uploaded photo, a dynamically generated image, or anything else that can be expressed as an Android Bitmap.
Setting the Delegate
InMainActivity.kt, the delegate is registered immediately after playAnimation():
MainActivity.kt
LottieImageAsset parameter (image) that describes the image reference found in the JSON — including its width, height, and the filename listed in the composition. The lambda must return a Bitmap.
What BitmapFactory.decodeResource Does
BitmapFactory.decodeResource(resources, R.drawable.logo) reads the file bound to the R.drawable.logo identifier — in this project that is res/drawable/logo.webp — and decodes it into an in-memory Bitmap object sized to the drawable’s native resolution. The resources reference comes from the Activity context and is used to locate the drawable inside the compiled APK.
This means every image slot in the Lottie JSON that triggers the delegate will be filled with the logo.webp drawable, effectively branding or templating the animation with a local asset.
When to Use This
Placeholder Image Replacement
Your Lottie JSON contains placeholder images (e.g., grey boxes exported from After Effects) that you want to swap out with real content at runtime — for example, a product photo or a user’s profile picture.
Template Animation Branding
You have a single template animation that multiple clients or users share, and you need to inject a different logo or banner image into it for each session without shipping separate JSON files per brand.
If the Lottie JSON file loaded into your
LottieAnimationView contains no embedded image references, the delegate is never invoked — you can safely register it without any effect on purely vector-based animations.