# SpringAnimation

Artifact: [androidx.dynamicanimation:dynamicanimation](https://developer.android.com/jetpack/androidx/releases/dynamicanimation) [View Source](https://cs.android.com/search?q=file:androidx/dynamicanimation/animation/SpringAnimation.java+class:androidx.dynamicanimation.animation.SpringAnimation) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

*** ** * ** ***


```
class SpringAnimation : DynamicAnimation<SpringAnimation!>
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.dynamicanimation.animation.DynamicAnimation](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation)\<[SpringAnimation](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation)!\> ||
|   | ↳ | [androidx.dynamicanimation.animation.SpringAnimation](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation) |

*** ** * ** ***

SpringAnimation is an animation that is driven by a `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce`. The spring force defines the spring's stiffness, damping ratio, as well as the rest position. Once the SpringAnimation is started, on each frame the spring force will update the animation's value and velocity. The animation will continue to run until the spring force reaches equilibrium. If the spring used in the animation is undamped, the animation will never reach equilibrium. Instead, it will oscillate forever.

To create a simple `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation` that uses the default `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce`:

```kotlin
// Create an animation to animate view's X property, set the rest position of the
// default spring to 0, and start the animation with a starting velocity of 5000 (pixel/s).
final SpringAnimation anim = new SpringAnimation(view, DynamicAnimation.X, 0)
        .setStartVelocity(5000);
anim.start();
```

Alternatively, a `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation` can take a pre-configured `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce`, and use that to drive the animation.

```kotlin
// Create a low stiffness, low bounce spring at position 0.
SpringForce spring = new SpringForce(0)
        .setDampingRatio(SpringForce.DAMPING_RATIO_LOW_BOUNCY)
        .setStiffness(SpringForce.STIFFNESS_LOW);
// Create an animation to animate view's scaleY property, and start the animation using
// the spring above and a starting value of 0.5. Additionally, constrain the range of value for
// the animation to be non-negative, effectively preventing any spring overshoot.
final SpringAnimation anim = new SpringAnimation(view, DynamicAnimation.SCALE_Y)
        .setMinValue(0).setSpring(spring).setStartValue(1);
anim.start();
```

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#SpringAnimation(androidx.dynamicanimation.animation.FloatValueHolder)(floatValueHolder: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder!)` This creates a SpringAnimation that animates a `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder` instance. |
| `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#SpringAnimation(androidx.dynamicanimation.animation.FloatValueHolder,float)(floatValueHolder: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder!, finalPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` This creates a SpringAnimation that animates a `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder` instance. |
| `<K> https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#SpringAnimation(K,androidx.dynamicanimation.animation.FloatPropertyCompat<K>)(object: K!, property: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat<K!>!)` This creates a SpringAnimation that animates the property of the given object. |
| `<K> https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#SpringAnimation(K,androidx.dynamicanimation.animation.FloatPropertyCompat<K>,float)( object: K!, property: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat<K!>!, finalPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` This creates a SpringAnimation that animates the property of the given object. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#animateToFinalPosition(float)(finalPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Updates the final position of the spring. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#canSkipToEnd()()` Queries whether the spring can eventually come to the rest position. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#cancel()()` Cancels the on-going animation. |
| `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce!` | `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#getSpring()()` Returns the spring that the animation uses for animations. |
| `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation!` | `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#setSpring(androidx.dynamicanimation.animation.SpringForce)(force: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce!)` Uses the given spring as the force that drives this animation. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#skipToEnd()()` Skips to the end of the animation. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/MainThread https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#start()()` Starts an animation. |

| ### Extension functions |
|---|---|
| `inline https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation` | `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation.https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#(androidx.dynamicanimation.animation.SpringAnimation).withSpringForceProperties(kotlin.Function1)(func: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Updates or applies spring force properties like `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce#mDampingRatio()`, `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce#mFinalPosition()` and stiffness on SpringAnimation. |

### Inherited Constants

From [androidx.dynamicanimation.animation.DynamicAnimation](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation) `const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#ALPHA()`

View's alpha property.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#MIN_VISIBLE_CHANGE_ALPHA() = 0.00390625f`

The minimum visible change in alpha that can be visible to users.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#MIN_VISIBLE_CHANGE_PIXELS() = 1.0f`

The minimum visible change in pixels that can be visible to users.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#MIN_VISIBLE_CHANGE_ROTATION_DEGREES() = 0.1f`

The minimum visible change in degrees that can be visible to users.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#MIN_VISIBLE_CHANGE_SCALE() = 0.002f`

The minimum visible change in scale that can be visible to users.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#ROTATION()`

View's rotation property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#ROTATION_X()`

View's rotationX property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#ROTATION_Y()`

View's rotationY property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#SCALE_X()`

View's scaleX property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#SCALE_Y()`

View's scaleY property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#SCROLL_X()`

View's scrollX property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#SCROLL_Y()`

View's scrollY property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#TRANSLATION_X()`

View's translationX property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#TRANSLATION_Y()`

View's translationY property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#TRANSLATION_Z()`

View's translationZ property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#X()`

View's x property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#Y()`

View's y property.
`const https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#Z()`

View's z property.

### Inherited functions

From [androidx.dynamicanimation.animation.DynamicAnimation](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation) `T!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#addEndListener(androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener)(listener: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.OnAnimationEndListener!)`

Adds an end listener to the animation for receiving onAnimationEnd callbacks.
`T!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#addUpdateListener(androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationUpdateListener)(listener: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.OnAnimationUpdateListener!)`

Adds an update listener to the animation for receiving per-frame animation update callbacks.
`https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/AnimationHandler` `@https://developer.android.com/reference/kotlin/androidx/annotation/VisibleForTesting
https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#getAnimationHandler()()`

Returns the `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/AnimationHandler` used to schedule updates for this animator.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#getMinimumVisibleChange()()`

Returns the minimum change in the animation property that could be visibly different to users.
`https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FrameCallbackScheduler` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#getScheduler()()`

Returns the `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FrameCallbackScheduler` used to schedule updates for this animator.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#isRunning()()`

Returns whether the animation is currently running.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#removeEndListener(androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener)(listener: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.OnAnimationEndListener!)`

Removes the end listener from the animation, so as to stop receiving animation end callbacks.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#removeUpdateListener(androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationUpdateListener)(
listener: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.OnAnimationUpdateListener!
)`

Removes the update listener from the animation, so as to stop receiving animation update callbacks.
`T!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#setMaxValue(float)(max: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Sets the max value of the animation.
`T!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#setMinValue(float)(min: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Sets the min value of the animation.
`T!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#setMinimumVisibleChange(float)(
minimumVisibleChange: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, fromInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html
)`

This method sets the minimal change of animation value that is visible to users, which helps determine a reasonable threshold for the animation's termination condition.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#setScheduler(androidx.dynamicanimation.animation.FrameCallbackScheduler)(scheduler: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FrameCallbackScheduler)`

Sets the frame scheduler used to schedule updates for this animator.
`T!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#setStartValue(float)(startValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Sets the start value of the animation.
`T!` `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#setStartVelocity(float)(startVelocity: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`

Start velocity of the animation.

## Public constructors

### SpringAnimation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
SpringAnimation(floatValueHolder: FloatValueHolder!)
```

This creates a SpringAnimation that animates a `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder` instance. During the animation, the `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder` instance will be updated via `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float)` each frame. The caller can obtain the up-to-date animation value via `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#getValue()`.

**Note:** changing the value in the `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder` via `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float)` outside of the animation during an animation run will not have any effect on the on-going animation.

| Parameters |
|---|---|
| `floatValueHolder: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder!` | the property to be animated |

### SpringAnimation

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.1.0)

```
SpringAnimation(floatValueHolder: FloatValueHolder!, finalPosition: Float)
```

This creates a SpringAnimation that animates a `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder` instance. During the animation, the `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder` instance will be updated via `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float)` each frame. The caller can obtain the up-to-date animation value via `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#getValue()`. A Spring will be created with the given final position and default stiffness and damping ratio. This spring can be accessed and reconfigured through `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#setSpring(androidx.dynamicanimation.animation.SpringForce)`.

**Note:** changing the value in the `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder` via `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float)` outside of the animation during an animation run will not have any effect on the on-going animation.

| Parameters |
|---|---|
| `floatValueHolder: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder!` | the property to be animated |
| `finalPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the final position of the spring to be created. |

### SpringAnimation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
<K> SpringAnimation(object: K!, property: FloatPropertyCompat<K!>!)
```

This creates a SpringAnimation that animates the property of the given object. Note, a spring will need to setup through `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#setSpring(androidx.dynamicanimation.animation.SpringForce)` before the animation starts.

| Parameters |
|---|---|
| `<K>` | the class on which the Property is declared |
| `object: K!` | the Object whose property will be animated |
| `property: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat<K!>!` | the property to be animated |

### SpringAnimation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
<K> SpringAnimation(
    object: K!,
    property: FloatPropertyCompat<K!>!,
    finalPosition: Float
)
```

This creates a SpringAnimation that animates the property of the given object. A Spring will be created with the given final position and default stiffness and damping ratio. This spring can be accessed and reconfigured through `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#setSpring(androidx.dynamicanimation.animation.SpringForce)`.

| Parameters |
|---|---|
| `<K>` | the class on which the Property is declared |
| `object: K!` | the Object whose property will be animated |
| `property: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat<K!>!` | the property to be animated |
| `finalPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | the final position of the spring to be created. |

## Public functions

### animateToFinalPosition

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
fun animateToFinalPosition(finalPosition: Float): Unit
```

Updates the final position of the spring.
When the animation is running, calling this method would assume the position change of the spring as a continuous movement since last frame, which yields more accurate results than changing the spring position directly through `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce#setFinalPosition(float)`. If the animation hasn't started, calling this method will change the spring position, and immediately start the animation.

| Parameters |
|---|---|
| `finalPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | rest position of the spring |

### canSkipToEnd

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
fun canSkipToEnd(): Boolean
```

Queries whether the spring can eventually come to the rest position.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `true` if the spring is damped, otherwise `false` |

### cancel

```
@MainThread
fun cancel(): Unit
```

Cancels the on-going animation. If the animation hasn't started, no op. Note that this method should only be called on main thread.

| Throws |
|---|---|
| `https://developer.android.com/reference/android/util/AndroidRuntimeException.html` | if this method is not called on the main thread |

### getSpring

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
fun getSpring(): SpringForce!
```

Returns the spring that the animation uses for animations.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce!` | the spring that the animation uses for animations |

### setSpring

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
fun setSpring(force: SpringForce!): SpringAnimation!
```

Uses the given spring as the force that drives this animation. If this spring force has its parameters re-configured during the animation, the new configuration will be reflected in the animation immediately.

| Parameters |
|---|---|
| `force: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce!` | a pre-defined spring force that drives the animation |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation!` | the animation that the spring force is set on |

### skipToEnd

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
fun skipToEnd(): Unit
```

Skips to the end of the animation. If the spring is undamped, an `https://developer.android.com/reference/java/lang/IllegalStateException.html` will be thrown, as the animation would never reach to an end. It is recommended to check `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#canSkipToEnd()` before calling this method. If animation is not running, no-op. Unless a AnimationHandler is provided via setAnimationHandler, a default AnimationHandler is created on the same thread as the first call to start/cancel an animation. All the subsequent animation lifecycle manipulations need to be on that same thread, until the AnimationHandler is reset (using \[setAnimationHandler\]).

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the spring is undamped (i.e. damping ratio = 0) |
| `https://developer.android.com/reference/android/util/AndroidRuntimeException.html` | if this method is not called on the same thread as the animation handler |

### start

```
@MainThread
fun start(): Unit
```

Starts an animation. If the animation has already been started, no op. Note that calling `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation#start()` will not immediately set the property value to start value of the animation. The property values will be changed at each animation pulse, which happens before the draw pass. As a result, the changes will be reflected in the next frame, the same as if the values were set immediately. This method should only be called on main thread. Unless a AnimationHandler is provided via setAnimationHandler, a default AnimationHandler is created on the same thread as the first call to start/cancel an animation. All the subsequent animation lifecycle manipulations need to be on that same thread, until the AnimationHandler is reset (using \[setAnimationHandler\]).

| Throws |
|---|---|
| `https://developer.android.com/reference/android/util/AndroidRuntimeException.html` | if this method is not called on the same thread as the animation handler |

## Extension functions

### SpringAnimation.withSpringForceProperties

Artifact: [androidx.dynamicanimation:dynamicanimation-ktx](https://developer.android.com/jetpack/androidx/releases/dynamicanimation) [View Source](https://cs.android.com/search?q=file:androidx/dynamicanimation/animation/DynamicAnimation.kt+function:withSpringForceProperties)

```
inline fun SpringAnimation.withSpringForceProperties(func: SpringForce.() -> Unit): SpringAnimation
```

Updates or applies spring force properties like `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce#mDampingRatio()`, `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce#mFinalPosition()` and stiffness on SpringAnimation.

If `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#mSpring()` is null in case `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation` is created without final position it will be created and attached to `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation`

| Parameters |
|---|---|
| `func: https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | lambda with receiver on `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringForce` |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation` | `https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation` |