# DynamicAnimationKt

Added in 1.0.0

*** ** * ** ***


```
public final class DynamicAnimationKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/dynamicanimation/animation/FlingAnimation` | `https://developer.android.com/reference/androidx/dynamicanimation/animation/DynamicAnimationKt#flingAnimationOf(kotlin.Function1,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> setter, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html> getter )` Creates `https://developer.android.com/reference/androidx/dynamicanimation/animation/FlingAnimation` for a property that can be accessed via the provided setter and getter. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringAnimation` | `https://developer.android.com/reference/androidx/dynamicanimation/animation/DynamicAnimationKt#springAnimationOf(kotlin.Function1,kotlin.Function0,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> setter, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html> getter, float finalPosition )` Creates `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringAnimation` for a property that can be accessed via the provided setter and getter. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringAnimation` | `https://developer.android.com/reference/androidx/dynamicanimation/animation/DynamicAnimationKt#(androidx.dynamicanimation.animation.SpringAnimation).withSpringForceProperties(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringAnimation receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringForce, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> func )` Updates or applies spring force properties like `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringForce#mDampingRatio()`, `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringForce#mFinalPosition()` and stiffness on SpringAnimation. |

## Public methods

### flingAnimationOf

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:flingAnimationOf) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
public static final @NonNull FlingAnimation flingAnimationOf(
    @NonNull Function1<@NonNull Float, Unit> setter,
    @NonNull Function0<@NonNull Float> getter
)
```

Creates `https://developer.android.com/reference/androidx/dynamicanimation/animation/FlingAnimation` for a property that can be accessed via the provided setter and getter. For example, the following sample code creates a `https://developer.android.com/reference/androidx/dynamicanimation/animation/FlingAnimation` for the alpha property of a View object named `view`: `flingAnimationOf(view::setAlpha, view::getAlpha)`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> setter` | The function that mutates the property being animated |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html> getter` | The function that returns the value of the property |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/dynamicanimation/animation/FlingAnimation` | `https://developer.android.com/reference/androidx/dynamicanimation/animation/FlingAnimation` |

### springAnimationOf

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:springAnimationOf) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
public static final @NonNull SpringAnimation springAnimationOf(
    @NonNull Function1<@NonNull Float, Unit> setter,
    @NonNull Function0<@NonNull Float> getter,
    float finalPosition
)
```

Creates `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringAnimation` for a property that can be accessed via the provided setter and getter. If finalPosition is not `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/-companion/-na-n.html` then create `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringAnimation` with `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringForce#mFinalPosition()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> setter` | The function that mutates the property being animated |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Float.html> getter` | The function that returns the value of the property |
| `float finalPosition` | `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringForce#mFinalPosition()` Final position of spring. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringAnimation` | `https://developer.android.com/reference/androidx/dynamicanimation/animation/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) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/dynamicanimation#1.0.0)

```
public static final @NonNull SpringAnimation withSpringForceProperties(
    @NonNull SpringAnimation receiver,
    @NonNull Function1<@NonNull SpringForce, Unit> func
)
```

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

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringForce, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> func` | lambda with receiver on `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringForce` |

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