# FloatValueHolder

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/dynamicanimation/animation/FloatValueHolder "View this page in Java")

<br />

```
class FloatValueHolder
```

<br />

*** ** * ** ***

FloatValueHolder holds a float value. FloatValueHolder provides a setter and a getter ( i.e.[setValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float))and[getValue](https://developer.android.com/reference/kotlin/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[setValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float)). The caller can obtain the up-to-date animation value via[getValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#getValue()).

Here is an example for creating a[FlingAnimation](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FlingAnimation)with a FloatValueHolder:  

```kotlin
// 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                                                                                           |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [SpringAnimation](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/SpringAnimation#SpringAnimation(androidx.dynamicanimation.animation.FloatValueHolder)) |   |
| [FlingAnimation](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FlingAnimation#FlingAnimation(androidx.dynamicanimation.animation.FloatValueHolder))    |   |

## Summary

|                                                                                                                                                  ### Public constructors                                                                                                                                                  |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FloatValueHolder](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#FloatValueHolder())`()` Constructs a holder for a float value that is initialized to 0.                                                                                                            |
| [FloatValueHolder](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#FloatValueHolder(float))`(value: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Constructs a holder for a float value that is initialized to the input value. |

|                              ### Public functions                               |
|---------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [getValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#getValue())`()` Returns the float value held in the FloatValueHolder instance.                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)   | [setValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatValueHolder#setValue(float))`(value: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` 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)  

```
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)  

```
FloatValueHolder(value: Float)
```

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

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| `value: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | the value to initialize the value held in the FloatValueHolder |

## Public functions

### getValue

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

```
fun getValue(): Float
```

Returns the float value held in the FloatValueHolder instance.  

|                                     Returns                                     |
|---------------------------------------------------------------------------------|---------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | float value held in the FloatValueHolder instance |

### setValue

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

```
fun setValue(value: Float): Unit
```

Sets the value held in the FloatValueHolder instance.  

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|---------------------------------------------------|
| `value: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | float value held in the FloatValueHolder instance |