Google is committed to advancing racial equity for Black communities. See how.

RepeatableSpec

class RepeatableSpec<T> : AnimationSpec<T>
kotlin.Any
   ↳ androidx.animation.RepeatableSpec

RepeatableSpec takes another DurationBasedAnimationSpec and plays it iterations times.

Note: When repeating in the RepeatMode.Reverse mode, it's highly recommended to have an odd number of iterations, or AnimationConstants.Infinite iterations. Otherwise, the animation may jump to the end value when it finishes the last iteration.

Summary

Public constructors
<init>(iterations: Int, animation: DurationBasedAnimationSpec<T>, repeatMode: RepeatMode = RepeatMode.Restart)

RepeatableSpec takes another DurationBasedAnimationSpec and plays it iterations times.

Public methods
VectorizedAnimationSpec<V>
vectorize(converter: TwoWayConverter<T, V>)

Creates a VectorizedAnimationSpec with the given TwoWayConverter.

Properties
DurationBasedAnimationSpec<T>

the AnimationSpec to be repeated

Int

the count of iterations.

RepeatMode

whether animation should repeat by starting from the beginning (i.

Public constructors

<init>

RepeatableSpec(
    iterations: Int,
    animation: DurationBasedAnimationSpec<T>,
    repeatMode: RepeatMode = RepeatMode.Restart)

RepeatableSpec takes another DurationBasedAnimationSpec and plays it iterations times.

Note: When repeating in the RepeatMode.Reverse mode, it's highly recommended to have an odd number of iterations, or AnimationConstants.Infinite iterations. Otherwise, the animation may jump to the end value when it finishes the last iteration.

Parameters
iterations: Int the count of iterations. Should be at least 1. AnimationConstants.Infinite can be used to have an infinity repeating animation.
animation: DurationBasedAnimationSpec<T> the AnimationSpec to be repeated
repeatMode: RepeatMode = RepeatMode.Restart whether animation should repeat by starting from the beginning (i.e. RepeatMode.Restart) or from the end (i.e. RepeatMode.Reverse)

Public methods

vectorize

fun <V : AnimationVector> vectorize(converter: TwoWayConverter<T, V>): VectorizedAnimationSpec<V>

Creates a VectorizedAnimationSpec with the given TwoWayConverter.

The underlying animation system operates on AnimationVectors. T will be converted to AnimationVector to animate. VectorizedAnimationSpec describes how the converted AnimationVector should be animated. E.g. The animation could simply interpolate between the start and end values (i.e.TweenSpec), or apply spring physics to produce the motion (i.e. SpringSpec), etc)

Parameters
converter: TwoWayConverter<T, V> converts the type T from and to AnimationVector type

Properties

animation

val animation: DurationBasedAnimationSpec<T>

the AnimationSpec to be repeated

iterations

val iterations: Int

the count of iterations. Should be at least 1. AnimationConstants.Infinite can be used to have an infinity repeating animation.

repeatMode

val repeatMode: RepeatMode

whether animation should repeat by starting from the beginning (i.e. RepeatMode.Restart) or from the end (i.e. RepeatMode.Reverse)