added in [version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)   
belongs to Maven artifact com.android.support:support-dynamic-animation:28.0.0-alpha1 Summary: [Inherited Constants](https://developer.android.com/reference/android/support/animation/FlingAnimation#inhconstants) \| [Inherited Fields](https://developer.android.com/reference/android/support/animation/FlingAnimation#inhfields) \| [Ctors](https://developer.android.com/reference/android/support/animation/FlingAnimation#pubctors) \| [Methods](https://developer.android.com/reference/android/support/animation/FlingAnimation#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/support/animation/FlingAnimation#inhmethods) \| [\[Expand All\]](https://developer.android.com/reference/android/support/animation/FlingAnimation#)

# FlingAnimation

| This package is part of the Android [support library](https://developer.android.com/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](https://developer.android.com/jetpack/androidx) which is part of [Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](https://developer.android.com/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class
| mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).


`
public

final

class
FlingAnimation
`


`


`

`

extends https://developer.android.com/reference/android/support/animation/DynamicAnimation<https://developer.android.com/reference/android/support/animation/FlingAnimation>


`

`


`

|---|---|---|
| java.lang.Object |||
| ↳ | [android.support.animation.DynamicAnimation](https://developer.android.com/reference/android/support/animation/DynamicAnimation)\<[android.support.animation.FlingAnimation](https://developer.android.com/reference/android/support/animation/FlingAnimation)\> ||
|   | ↳ | android.support.animation.FlingAnimation |

<br />

*** ** * ** ***

<br />

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 `https://developer.android.com/reference/android/support/animation/DynamicAnimation#setMinimumVisibleChange(float)`,
or when the value of the animation has gone beyond the min or max value defined via
`https://developer.android.com/reference/android/support/animation/DynamicAnimation#setMinValue(float)` or `https://developer.android.com/reference/android/support/animation/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:

```scdoc
 FlingAnimation flingAnim = new FlingAnimation(view, DynamicAnimation.TRANSLATION_X)
         // Sets the start velocity to -2000 (pixel/s)
         .setStartVelocity(-2000)
         // 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.
         .setMinValue(-200).setMaxValue(2000);
 flingAnim.start();
 
```

<br />

## Summary

| ### Inherited constants |
|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/animation/FlingAnimation#)From class ` https://developer.android.com/reference/android/support/animation/DynamicAnimation ` |---|---| | `float` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#MIN_VISIBLE_CHANGE_ALPHA` The minimum visible change in alpha that can be visible to users. | | `float` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#MIN_VISIBLE_CHANGE_PIXELS` The minimum visible change in pixels that can be visible to users. | | `float` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#MIN_VISIBLE_CHANGE_ROTATION_DEGREES` The minimum visible change in degrees that can be visible to users. | | `float` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#MIN_VISIBLE_CHANGE_SCALE` The minimum visible change in scale that can be visible to users. | |

| ### Inherited fields |
|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/animation/FlingAnimation#)From class ` https://developer.android.com/reference/android/support/animation/DynamicAnimation ` |---|---| | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#ALPHA` View's alpha property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#ROTATION` View's rotation property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#ROTATION_X` View's rotationX property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#ROTATION_Y` View's rotationY property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#SCALE_X` View's scaleX property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#SCALE_Y` View's scaleY property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#SCROLL_X` View's scrollX property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#SCROLL_Y` View's scrollY property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#TRANSLATION_X` View's translationX property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#TRANSLATION_Y` View's translationY property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#TRANSLATION_Z` View's translationZ property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#X` View's x property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#Y` View's y property. | | ` public static final https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty` | `https://developer.android.com/reference/android/support/animation/DynamicAnimation#Z` View's z property. | |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/support/animation/FlingAnimation#FlingAnimation(android.support.animation.FloatValueHolder)(https://developer.android.com/reference/android/support/animation/FloatValueHolder floatValueHolder) ` <br /> This creates a FlingAnimation that animates a `https://developer.android.com/reference/android/support/animation/FloatValueHolder` instance. |
| ` https://developer.android.com/reference/android/support/animation/FlingAnimation#FlingAnimation(K, android.support.animation.FloatPropertyCompat<K>)(K object, https://developer.android.com/reference/android/support/animation/FloatPropertyCompat<K> property) ` This creates a FlingAnimation that animates the property of the given object. |

| ### Public methods ||
|---|---|
| ` float` | ` https://developer.android.com/reference/android/support/animation/FlingAnimation#getFriction()() ` Returns the friction being set on the animation via `https://developer.android.com/reference/android/support/animation/FlingAnimation#setFriction(float)`. |
| ` https://developer.android.com/reference/android/support/animation/FlingAnimation` | ` https://developer.android.com/reference/android/support/animation/FlingAnimation#setFriction(float)(float friction) ` Sets the friction for the fling animation. |
| ` https://developer.android.com/reference/android/support/animation/FlingAnimation` | ` https://developer.android.com/reference/android/support/animation/FlingAnimation#setMaxValue(float)(float maxValue) ` Sets the max value of the animation. |
| ` https://developer.android.com/reference/android/support/animation/FlingAnimation` | ` https://developer.android.com/reference/android/support/animation/FlingAnimation#setMinValue(float)(float minValue) ` Sets the min value of the animation. |
| ` https://developer.android.com/reference/android/support/animation/FlingAnimation` | ` https://developer.android.com/reference/android/support/animation/FlingAnimation#setStartVelocity(float)(float startVelocity) ` Start velocity of the animation. |

| ### Inherited methods |
|---|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/animation/FlingAnimation#)From class ` https://developer.android.com/reference/android/support/animation/DynamicAnimation ` |---|---| | ` T` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#addEndListener(android.support.animation.DynamicAnimation.OnAnimationEndListener)(https://developer.android.com/reference/android/support/animation/DynamicAnimation.OnAnimationEndListener listener) ` Adds an end listener to the animation for receiving onAnimationEnd callbacks. | | ` T` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#addUpdateListener(android.support.animation.DynamicAnimation.OnAnimationUpdateListener)(https://developer.android.com/reference/android/support/animation/DynamicAnimation.OnAnimationUpdateListener listener) ` Adds an update listener to the animation for receiving per-frame animation update callbacks. | | ` void` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#cancel()() ` Cancels the on-going animation. | | ` float` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#getMinimumVisibleChange()() ` Returns the minimum change in the animation property that could be visibly different to users. | | ` boolean` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#isRunning()() ` Returns whether the animation is currently running. | | ` void` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#removeEndListener(android.support.animation.DynamicAnimation.OnAnimationEndListener)(https://developer.android.com/reference/android/support/animation/DynamicAnimation.OnAnimationEndListener listener) ` Removes the end listener from the animation, so as to stop receiving animation end callbacks. | | ` void` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#removeUpdateListener(android.support.animation.DynamicAnimation.OnAnimationUpdateListener)(https://developer.android.com/reference/android/support/animation/DynamicAnimation.OnAnimationUpdateListener listener) ` Removes the update listener from the animation, so as to stop receiving animation update callbacks. | | ` T` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#setMaxValue(float)(float max) ` Sets the max value of the animation. | | ` T` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#setMinValue(float)(float min) ` Sets the min value of the animation. | | ` T` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#setMinimumVisibleChange(float)(float minimumVisibleChange) ` This method sets the minimal change of animation value that is visible to users, which helps determine a reasonable threshold for the animation's termination condition. | | ` T` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#setStartValue(float)(float startValue) ` Sets the start value of the animation. | | ` T` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#setStartVelocity(float)(float startVelocity) ` Start velocity of the animation. | | ` void` | ` https://developer.android.com/reference/android/support/animation/DynamicAnimation#start()() ` Starts an animation. | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/animation/FlingAnimation#)From class ` java.lang.Object ` |---|---| | ` Object` | ` clone() ` | | ` boolean` | ` equals(Object arg0) ` | | ` void` | ` finalize() ` | | ` final Class<?>` | ` getClass() ` | | ` int` | ` hashCode() ` | | ` final void` | ` notify() ` | | ` final void` | ` notifyAll() ` | | ` String` | ` toString() ` | | ` final void` | ` wait(long arg0, int arg1) ` | | ` final void` | ` wait(long arg0) ` | | ` final void` | ` wait() ` | ||

## Public constructors

### FlingAnimation

added in [version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
FlingAnimation (FloatValueHolder floatValueHolder)
```

<br />

This creates a FlingAnimation that animates a `https://developer.android.com/reference/android/support/animation/FloatValueHolder` instance. During
the animation, the `https://developer.android.com/reference/android/support/animation/FloatValueHolder` instance will be updated via
`https://developer.android.com/reference/android/support/animation/FloatValueHolder#setValue(float)` each frame. The caller can obtain the up-to-date
animation value via `https://developer.android.com/reference/android/support/animation/FloatValueHolder#getValue()`.

**Note:** changing the value in the `https://developer.android.com/reference/android/support/animation/FloatValueHolder` via
`https://developer.android.com/reference/android/support/animation/FloatValueHolder#setValue(float)` outside of the animation during an
animation run will not have any effect on the on-going animation.

<br />

| Parameters ||
|---|---|
| `floatValueHolder` | `FloatValueHolder`: the property to be animated <br /> |

### FlingAnimation

added in [version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
FlingAnimation (K object, 
                FloatPropertyCompat<K> property)
```

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

<br />

| Parameters ||
|---|---|
| `object` | `K`: the Object whose property will be animated <br /> |
| `property` | `FloatPropertyCompat`: the property to be animated <br /> |

## Public methods

### getFriction

added in [version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
float getFriction ()
```

Returns the friction being set on the animation via `https://developer.android.com/reference/android/support/animation/FlingAnimation#setFriction(float)`. If the
friction has not been set, the default friction of 1 will be returned.

<br />

| Returns ||
|---|---|
| `float` | friction being used in the animation <br /> |

### setFriction

added in [version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
FlingAnimation setFriction (float friction)
```

Sets the friction for the fling animation. The greater the friction is, the sooner the
animation will slow down. When not set, the friction defaults to 1.

<br />

| Parameters ||
|---|---|
| `friction` | `float`: the friction used in the animation Value is 0.0 or greater. |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/support/animation/FlingAnimation` | the animation whose friction will be scaled <br /> |

| Throws ||
|---|---|
| `IllegalArgumentException` | if the input friction is not positive |

### setMaxValue

added in [version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
FlingAnimation setMaxValue (float maxValue)
```

Sets the max value of the animation. When a fling animation reaches the max value, the
animation will end immediately. Animations will not animate beyond the max value.

<br />

| Parameters ||
|---|---|
| `maxValue` | `float`: maximum value of the property to be animated <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/support/animation/FlingAnimation` | the Animation whose max value is being set <br /> |

### setMinValue

added in [version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
FlingAnimation setMinValue (float minValue)
```

Sets the min value of the animation. When a fling animation reaches the min value, the
animation will end immediately. Animations will not animate beyond the min value.

<br />

| Parameters ||
|---|---|
| `minValue` | `float`: minimum value of the property to be animated <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/support/animation/FlingAnimation` | the Animation whose min value is being set <br /> |

### setStartVelocity

added in [version 25.4.0](https://developer.android.com/topic/libraries/support-library/revisions)

```
FlingAnimation setStartVelocity (float startVelocity)
```

Start velocity of the animation. Default velocity is 0. Unit: pixel/second

A **non-zero** start velocity is required for a FlingAnimation. If no start velocity is
set through `https://developer.android.com/reference/android/support/animation/FlingAnimation#setStartVelocity(float)`, the start velocity defaults to 0. In that
case, the fling animation will consider itself done in the next frame.

Note when using a fixed value as the start velocity (as opposed to getting the velocity
through touch events), it is recommended to define such a value in dp/second and convert it
to pixel/second based on the density of the screen to achieve a consistent look across
different screens.

To convert from dp/second to pixel/second:

```scdoc
 float pixelPerSecond = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpPerSecond,
         getResources().getDisplayMetrics());
 
```

<br />

<br />

| Parameters ||
|---|---|
| `startVelocity` | `float`: start velocity of the animation in pixel/second <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/support/animation/FlingAnimation` | the Animation whose start velocity is being set <br /> |

-

  ## Interfaces

  - [DynamicAnimation.OnAnimationEndListener](https://developer.android.com/reference/android/support/animation/DynamicAnimation.OnAnimationEndListener)
  - [DynamicAnimation.OnAnimationUpdateListener](https://developer.android.com/reference/android/support/animation/DynamicAnimation.OnAnimationUpdateListener)
-

  ## Classes

  - [DynamicAnimation](https://developer.android.com/reference/android/support/animation/DynamicAnimation)
  - [DynamicAnimation.ViewProperty](https://developer.android.com/reference/android/support/animation/DynamicAnimation.ViewProperty)
  - [FlingAnimation](https://developer.android.com/reference/android/support/animation/FlingAnimation)
  - [FloatPropertyCompat](https://developer.android.com/reference/android/support/animation/FloatPropertyCompat)
  - [FloatValueHolder](https://developer.android.com/reference/android/support/animation/FloatValueHolder)
  - [SpringAnimation](https://developer.android.com/reference/android/support/animation/SpringAnimation)
  - [SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce)