Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.


class FlingAnimation : DynamicAnimation<FlingAnimation!>
   ↳ androidx.dynamicanimation.animation.DynamicAnimation<androidx.dynamicanimation.animation.FlingAnimation>
   ↳ androidx.dynamicanimation.animation.FlingAnimation

Fling animation is an animation that continues an initial momentum (most often from gesture velocity) and gradually slows down. The fling animation will come to a stop when the velocity of the animation is below the threshold derived from setMinimumVisibleChange(float), or when the value of the animation has gone beyond the min or max value defined via DynamicAnimation#setMinValue(float) or DynamicAnimation#setMaxValue(float). It is recommended to restrict the fling animation with min and/or max value, such that the animation can end when it goes beyond screen bounds, thus preserving CPU cycles and resources.

For example, you can create a fling animation that animates the translationX of a view:

FlingAnimation flingAnim = new FlingAnimation(view, DynamicAnimation.TRANSLATION_X)
          // Sets the start velocity to -2000 (pixel/s)
          // Optional but recommended to set a reasonable min and max range for the animation.
          // In this particular case, we set the min and max to -200 and 2000 respectively.


Inherited constants
Public constructors
<init>(floatValueHolder: FloatValueHolder!)

This creates a FlingAnimation that animates a FloatValueHolder instance.

<init>(object: K, property: FloatPropertyCompat<K>!)

This creates a FlingAnimation that animates the property of the given object.

Public methods

Returns the friction being set on the animation via setFriction(float).

setFriction(@FloatRange(0.0, false) friction: Float)

Sets the friction for the fling animation.

setMaxValue(maxValue: Float)

Sets the max value of the animation.

setMinValue(minValue: Float)

Sets the min value of the animation.

setStartVelocity(startVelocity: Float)

Start velocity of the animation.

Inherited functions
Inherited properties

Public constructors


FlingAnimation(floatValueHolder: FloatValueHolder!)

This creates a FlingAnimation that animates a FloatValueHolder instance. During the animation, the FloatValueHolder instance will be updated via FloatValueHolder#setValue(float) each frame. The caller can obtain the up-to-date animation value via FloatValueHolder#getValue().

Note: changing the value in the FloatValueHolder via FloatValueHolder#setValue(float) outside of the animation during an animation run will not have any effect on the on-going animation.

floatValueHolder FloatValueHolder