{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SpringSpec

public final class SpringSpec<T extends Object> implements FiniteAnimationSpec


Creates a SpringSpec that uses the given spring constants (i.e. dampingRatio and stiffness. The optional visibilityThreshold defines when the animation should be considered to be visually close enough to round off to its target.

Summary

Public constructors

<T extends Object> SpringSpec(
    float dampingRatio,
    float stiffness,
    T visibilityThreshold
)

Public methods

boolean
equals(Object other)
final float

damping ratio of the spring.

final float

stiffness of the spring.

final T

specifies the visibility threshold

int
@NonNull VectorizedSpringSpec<@NonNull V>
<V extends AnimationVector> vectorize(
    @NonNull TwoWayConverter<@NonNull T, @NonNull V> converter
)

Creates a VectorizedAnimationSpec with the given TwoWayConverter.

Public constructors

SpringSpec

public <T extends Object> SpringSpec(
    float dampingRatio,
    float stiffness,
    T visibilityThreshold
)
Parameters
float dampingRatio

damping ratio of the spring. Spring.DampingRatioNoBouncy by default.

float stiffness

stiffness of the spring. Spring.StiffnessMedium by default.

T visibilityThreshold

specifies the visibility threshold

Public methods

equals

public boolean equals(Object other)

getDampingRatio

public final float getDampingRatio()

damping ratio of the spring. Spring.DampingRatioNoBouncy by default.

getStiffness

public final float getStiffness()

stiffness of the spring. Spring.StiffnessMedium by default.

getVisibilityThreshold

public final T getVisibilityThreshold()

specifies the visibility threshold

hashCode

public int hashCode()

vectorize

public @NonNull VectorizedSpringSpec<@NonNull V> <V extends AnimationVector> vectorize(
    @NonNull TwoWayConverter<@NonNull T, @NonNull V> converter
)

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
@NonNull TwoWayConverter<@NonNull T, @NonNull V> converter

converts the type T from and to AnimationVector type