# FloatPropertyCompat

# FloatPropertyCompat

Artifact:[androidx.dynamicanimation:dynamicanimation](https://developer.android.com/jetpack/androidx/releases/dynamicanimation)  
[View Source](https://cs.android.com/search?q=file:androidx/dynamicanimation/animation/FloatPropertyCompat.java+class:androidx.dynamicanimation.animation.FloatPropertyCompat)  
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/FloatPropertyCompat "View this page in Java")

<br />

```
abstract class FloatPropertyCompat<T>
```

<br />

Known direct subclasses  
[DynamicAnimation.ViewProperty](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty)  

|---------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
| [DynamicAnimation.ViewProperty](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/DynamicAnimation.ViewProperty) | ViewProperty holds the access of a property of a[View](https://developer.android.com/reference/android/view/View.html). |

*** ** * ** ***

FloatPropertyCompat is an abstraction that can be used to represent a mutable float value that is held in a host object. To access this float value,[setValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat#setValue(T,float))and getter[getValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat#getValue(T))need to be implemented. Both the setter and the getter take the primitive`float`type and avoids autoboxing and other overhead associated with the`Float`class.

For API 24 and later,[FloatProperty](https://developer.android.com/reference/android/util/FloatProperty.html)instances can be converted to[FloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat)through[createFloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat#createFloatPropertyCompat(android.util.FloatProperty<T>)).  

| Parameters |
|------------|---------------------------------------------|
| `<T>`      | the class on which the Property is declared |

## Summary

|                                                                                                                                             ### Public constructors                                                                                                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat#FloatPropertyCompat(java.lang.String))`(name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` A constructor that takes an identifying name. |

|                                                                ### Public functions                                                                |
|----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[FloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat)`<T!>!` | `@`[RequiresApi](https://developer.android.com/reference/kotlin/androidx/annotation/RequiresApi)`(value = 24)` `<T> `[createFloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat#createFloatPropertyCompat(android.util.FloatProperty<T>))`(property: `[FloatProperty](https://developer.android.com/reference/android/util/FloatProperty.html)`<T!>!)` Create a[FloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat)wrapper for a[FloatProperty](https://developer.android.com/reference/android/util/FloatProperty.html)object. |
| `abstract `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)                                                         | [getValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat#getValue(T))`(object: T!)` Returns the current value that this property represents on the given`object`.                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `abstract `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                                                           | [setValue](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat#setValue(T,float))`(object: T!, value: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Sets the value on`object`which this property represents.                                                                                                                                                                                                                                                                                                                                                                            |

## Public constructors

### FloatPropertyCompat

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

```
FloatPropertyCompat(name: String!)
```

A constructor that takes an identifying name.  

## Public functions

### createFloatPropertyCompat

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

```
@RequiresApi(value = 24)
java-static fun <T> createFloatPropertyCompat(property: FloatProperty<T!>!): FloatPropertyCompat<T!>!
```

Create a[FloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat)wrapper for a[FloatProperty](https://developer.android.com/reference/android/util/FloatProperty.html)object. The new[FloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat)instance will access and modify the property value of[FloatProperty](https://developer.android.com/reference/android/util/FloatProperty.html)through the[FloatProperty](https://developer.android.com/reference/android/util/FloatProperty.html)instance's setter and getter.  

|                                                 Parameters                                                  |
|-------------------------------------------------------------------------------------------------------------|---------------------------------------------|
| `<T>`                                                                                                       | the class on which the Property is declared |
| `property: `[FloatProperty](https://developer.android.com/reference/android/util/FloatProperty.html)`<T!>!` | FloatProperty instance to be wrapped        |

|                                                               Returns                                                                |
|--------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat)`<T!>!` | a new[FloatPropertyCompat](https://developer.android.com/reference/kotlin/androidx/dynamicanimation/animation/FloatPropertyCompat)wrapper for the given[FloatProperty](https://developer.android.com/reference/android/util/FloatProperty.html)object |

### getValue

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

```
abstract fun getValue(object: T!): Float
```

Returns the current value that this property represents on the given`object`.  

|  Parameters  |
|--------------|---------------------------------------|
| `object: T!` | object which this property represents |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | the current property value of the given object |

### setValue

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

```
abstract fun setValue(object: T!, value: Float): Unit
```

Sets the value on`object`which this property represents.  

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|---------------------------------------|
| `object: T!`                                                                             | object which this property represents |
| `value: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | new value of the property             |