Android 12 Developer Preview is here! Try it out, and give us your feedback!

RepeatableSpec

@Immutable class RepeatableSpec<T> : FiniteAnimationSpec<T>
kotlin.Any
   ↳ androidx.compose.animation.core.RepeatableSpec

RepeatableSpec takes another DurationBasedAnimationSpec and plays it iterations times. For creating infinitely repeating animation spec, consider using InfiniteRepeatableSpec.

Note: When repeating in the RepeatMode.Reverse mode, it's highly recommended to have an odd number of 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
Boolean
equals(other: Any?)

Int

VectorizedFiniteAnimationSpec<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. For creating infinitely repeating animation spec, consider using InfiniteRepeatableSpec.

Note: When repeating in the RepeatMode.Reverse mode, it's highly recommended to have an odd number of 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.
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

equals

fun equals(other: Any?): Boolean

hashCode

fun hashCode(): Int

vectorize

fun <V : AnimationVector> vectorize(converter: TwoWayConverter<T, V>): VectorizedFiniteAnimationSpec<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.

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)