animate

abstract suspend fun animate(composition: LottieComposition?, iteration: Int = this.iteration, iterations: Int = this.iterations, speed: Float = this.speed, clipSpec: LottieClipSpec? = this.clipSpec, initialProgress: Float = defaultProgress(composition, clipSpec, speed), continueFromPreviousAnimate: Boolean = false, cancellationBehavior: LottieCancellationBehavior = LottieCancellationBehavior.Immediately)

Animate a LottieComposition.

Parameters

composition

The LottieComposition that should be rendered.

iteration

The iteration to start the animation at. Defaults to 1 and carries over from previous animates.

iterations

The number of iterations to continue running for. Set to 1 to play one time set to LottieConstants.IterateForever to iterate forever. Can be set to arbitrary numbers. Defaults to 1 and carries over from previous animates.

speed

The speed at which the composition should be animated. Can be negative. Defaults to 1 and carries over from previous animates.

clipSpec

An optional LottieClipSpec to trim the playback of the composition between two values. Defaults to null and carries over from previous animates.

initialProgress

An optional progress value that the animation should start at. Defaults to the starting progress as defined by the clipSpec and speed. Because the default value isn't the existing progress value, if you are resuming an animation, you probably want to set this to progress.

continueFromPreviousAnimate

When set to true, instead of starting at the minimum progress, the initial progress will be advanced in accordance to the amount of time that has passed since the last frame was rendered.

cancellationBehavior

The behavior that this animation should have when cancelled. In most cases, you will want it to cancel immediately. However, if you have a state based transition and you want an animation to finish playing before moving on to the next one then you may want to set this to LottieCancellationBehavior.OnIterationFinish.