# FloatValueHolder

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

*** ** * ** ***


```
public class FloatValueHolder
```

<br />

*** ** * ** ***

FloatValueHolder holds a float value. FloatValueHolder provides a setter and a getter ( i.e. `https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float)` and `https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder#getValue()`) to access this float value. Animations can be performed on a FloatValueHolder instance. During each frame of the animation, the FloatValueHolder will have its value updated via `https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float)`. The caller can obtain the up-to-date animation value via `https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder#getValue()`.

Here is an example for creating a `https://developer.android.com/reference/androidx/dynamicanimation/animation/FlingAnimation` with a FloatValueHolder:

```
// Create a fling animation with an initial velocity of 5000 (pixel/s) and an initial position
// of 20f.
FloatValueHolder floatValueHolder = new FloatValueHolder(20f);
FlingAnimation anim = new FlingAnimation(floatValueHolder).setStartVelocity(5000);
anim.start();
```

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/dynamicanimation/animation/SpringAnimation#SpringAnimation(androidx.dynamicanimation.animation.FloatValueHolder)` |   |
| `https://developer.android.com/reference/androidx/dynamicanimation/animation/FlingAnimation#FlingAnimation(androidx.dynamicanimation.animation.FloatValueHolder)` |   |

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder#FloatValueHolder()()` Constructs a holder for a float value that is initialized to 0. |
| `https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder#FloatValueHolder(float)(float value)` Constructs a holder for a float value that is initialized to the input value. |

| ### Public methods |
|---|---|
| `float` | `https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder#getValue()()` Returns the float value held in the FloatValueHolder instance. |
| `void` | `https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float)(float value)` Sets the value held in the FloatValueHolder instance. |

## Public constructors

### FloatValueHolder

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

```
public FloatValueHolder()
```

Constructs a holder for a float value that is initialized to 0.

### FloatValueHolder

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

```
public FloatValueHolder(float value)
```

Constructs a holder for a float value that is initialized to the input value.

| Parameters |
|---|---|
| `float value` | the value to initialize the value held in the FloatValueHolder |

## Public methods

### getValue

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

```
public float getValue()
```

Returns the float value held in the FloatValueHolder instance.

| Returns |
|---|---|
| `float` | float value held in the FloatValueHolder instance |

### setValue

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

```
public void setValue(float value)
```

Sets the value held in the FloatValueHolder instance.

| Parameters |
|---|---|
| `float value` | float value held in the FloatValueHolder instance |