Register now for Android Dev Summit 2019!

androidx.dynamicanimation.animation

Classes

DynamicAnimation

This class is the base class of physics-based animations.

FlingAnimation

Fling animation is an animation that continues an initial momentum (most often from gesture velocity) and gradually slows down.

FloatPropertyCompat

FloatPropertyCompat is an abstraction that can be used to represent a mutable float value that is held in a host object.

FloatValueHolder

FloatValueHolder holds a float value.

SpringAnimation

SpringAnimation is an animation that is driven by a SpringForce.

SpringForce

Spring Force defines the characteristics of the spring being used in the animation.

Top-level functions summary

FlingAnimation
flingAnimationOf(setter: (Float) -> Unit, getter: () -> Float)

Creates FlingAnimation for a property that can be accessed via the provided setter and getter.

SpringAnimation
springAnimationOf(setter: (Float) -> Unit, getter: () -> Float, finalPosition: Float = Float.NaN)

Creates SpringAnimation for a property that can be accessed via the provided setter and getter.

Extension functions summary

For SpringAnimation
SpringAnimation

Updates or applies spring force properties like SpringForce.mDampingRatio, SpringForce.mFinalPosition and stiffness on SpringAnimation.

Top-level functions

flingAnimationOf

fun flingAnimationOf(setter: (Float) -> Unit, getter: () -> Float): FlingAnimation

Creates FlingAnimation for a property that can be accessed via the provided setter and getter. For example, the following sample code creates a FlingAnimation for the alpha property of a View object named view: flingAnimationOf(view::setAlpha, view::getAlpha)

Parameters
setter The function that mutates the property being animated
getter The function that returns the value of the property
Return
FlingAnimation

springAnimationOf

fun springAnimationOf(setter: (Float) -> Unit, getter: () -> Float, finalPosition: Float = Float.NaN): SpringAnimation

Creates SpringAnimation for a property that can be accessed via the provided setter and getter. If finalPosition is not Float.NaN then create SpringAnimation with SpringForce.mFinalPosition.

Parameters
setter The function that mutates the property being animated
getter The function that returns the value of the property
finalPosition SpringForce.mFinalPosition Final position of spring.
Return
SpringAnimation

Extension functions

withSpringForceProperties

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

Updates or applies spring force properties like SpringForce.mDampingRatio, SpringForce.mFinalPosition and stiffness on SpringAnimation.

If SpringAnimation.mSpring is null in case SpringAnimation is created without final position it will be created and attached to SpringAnimation

Parameters
func lambda with receiver on SpringForce
Return
SpringAnimation