compose/ui/DotLottieAnimation Composable Function API Reference

This reference details the parameters and their functionalities for the DotLottieAnimation composable function, enabling developers to integrate and control dotLottie animations within their Jetpack Compose UIs.

Parameters

ParameterDescriptionTypeDefault Value
modifierThe modifier to be applied to the animation view.ModifierModifier
source*The URL source of the animation.DotLottieSourcenull
autoplayDetermines if the animation will start playing automatically.Booleanfalse
loopDetermines whether the animation should loop.Booleanfalse
useFrameInterpolationEnables or disables frame interpolation for smoother animation.Booleantrue
themeIdThe themeId to be loadedStringnull
markerThe segment name or marker to be playedStringnull
speedThe playback speed of the animation.Float1f
segmentThe segment to be playedPair<Float, Float>null
playModeThe play mode of the animation (e.g., forward, reverse).ModeMode.FORWARD
controllerThe controller for managing animation playback and state.DotLottieControllernull
layoutSets the the layout of the AnimationLayoutcreateDefaultLayout()
eventListenersA list of event listeners for animation events.List<DotLottieEventListener>emptyList()

Functionality

  • Loading Animations: The DotLottieAnimation composable function supports loading animations from various sources, including URLs 1, asset files 2, or raw data 3. At least one source must be provided.
  • Playback Control: The function integrates with DotLottieController for controlling animation playback, including play, pause, and stop functionalities. The autoplay and loop parameters provide initial playback behavior.
  • Customization: Parameters such as speed, playMode, and useFrameInterpolation allow for customization of the animation playback, including its speed, direction, and smoothness.
  • Event Handling: The eventListeners parameter allows developers to attach multiple event listeners to handle various animation events, such as loading errors or completion.

Example Usage

DotLottieAnimation(
modifier = Modifier.background(Color.Red),
src = DotLottieSource.Url("https://example.com/animation.lottie"),
autoplay = true,
loop = true,
speed = 1.5f,
playMode = Mode.FORWARD,
controller = DotLottieController(),
eventListeners = listOf(DotLottieEventListener { event ->
// Handle animation events here
})
)

This API reference provides a comprehensive overview of the DotLottieAnimation composable function, enabling developers to effectively utilize dotLottie animations within their Jetpack Compose applications.