# SpringForce

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:[Constants](https://developer.android.com/reference/android/support/animation/SpringForce#constants)\|[Ctors](https://developer.android.com/reference/android/support/animation/SpringForce#pubctors)\|[Methods](https://developer.android.com/reference/android/support/animation/SpringForce#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/animation/SpringForce#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/animation/SpringForce#)  

# SpringForce

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

extends Object


``


`

|---|---------------------------------------|
| java.lang.Object                         ||
| ↳ | android.support.animation.SpringForce |

<br />

*** ** * ** ***

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

By configuring the stiffness and damping ratio, callers can create a spring with the look and feel suits their use case. Stiffness corresponds to the spring constant. The stiffer the spring is, the harder it is to stretch it, the faster it undergoes dampening.

Spring damping ratio describes how oscillations in a system decay after a disturbance. When damping ratio \> 1\* (i.e. over-damped), the object will quickly return to the rest position without overshooting. If damping ratio equals to 1 (i.e. critically damped), the object will return to equilibrium within the shortest amount of time. When damping ratio is less than 1 (i.e. under-damped), the mass tends to overshoot, and return, and overshoot again. Without any damping (i.e. damping ratio = 0), the mass will oscillate forever.

## Summary

|                                                                                        ### Constants                                                                                        ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `float` | [DAMPING_RATIO_HIGH_BOUNCY](https://developer.android.com/reference/android/support/animation/SpringForce#DAMPING_RATIO_HIGH_BOUNCY) Damping ratio for a very bouncy spring.       |
| `float` | [DAMPING_RATIO_LOW_BOUNCY](https://developer.android.com/reference/android/support/animation/SpringForce#DAMPING_RATIO_LOW_BOUNCY) Damping ratio for a spring with low bounciness. |
| `float` | [DAMPING_RATIO_MEDIUM_BOUNCY](https://developer.android.com/reference/android/support/animation/SpringForce#DAMPING_RATIO_MEDIUM_BOUNCY) Damping ratio for a medium bouncy spring. |
| `float` | [DAMPING_RATIO_NO_BOUNCY](https://developer.android.com/reference/android/support/animation/SpringForce#DAMPING_RATIO_NO_BOUNCY) Damping ratio for a spring with no bounciness.    |
| `float` | [STIFFNESS_HIGH](https://developer.android.com/reference/android/support/animation/SpringForce#STIFFNESS_HIGH) Stiffness constant for extremely stiff spring.                      |
| `float` | [STIFFNESS_LOW](https://developer.android.com/reference/android/support/animation/SpringForce#STIFFNESS_LOW) Stiffness constant for a spring with low stiffness.                   |
| `float` | [STIFFNESS_MEDIUM](https://developer.android.com/reference/android/support/animation/SpringForce#STIFFNESS_MEDIUM) Stiffness constant for medium stiff spring.                     |
| `float` | [STIFFNESS_VERY_LOW](https://developer.android.com/reference/android/support/animation/SpringForce#STIFFNESS_VERY_LOW) Stiffness constant for a spring with very low stiffness.    |

|                                                                                     ### Public constructors                                                                                      ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce#SpringForce())`() ` Creates a spring force.                                                    |
| ` `[SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce#SpringForce(float))`(float finalPosition) ` Creates a spring with a given final rest position. |

|                                                                                                                                                            ### Public methods                                                                                                                                                             ||
|-------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` float`                                                                                        | ` `[getDampingRatio](https://developer.android.com/reference/android/support/animation/SpringForce#getDampingRatio())`() ` Returns the damping ratio of the spring.                                                                      |
| ` float`                                                                                        | ` `[getFinalPosition](https://developer.android.com/reference/android/support/animation/SpringForce#getFinalPosition())`() ` Returns the rest position of the spring.                                                                    |
| ` float`                                                                                        | ` `[getStiffness](https://developer.android.com/reference/android/support/animation/SpringForce#getStiffness())`() ` Gets the stiffness of the spring.                                                                                   |
| ` `[SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce) | ` `[setDampingRatio](https://developer.android.com/reference/android/support/animation/SpringForce#setDampingRatio(float))`(float dampingRatio) ` Spring damping ratio describes how oscillations in a system decay after a disturbance. |
| ` `[SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce) | ` `[setFinalPosition](https://developer.android.com/reference/android/support/animation/SpringForce#setFinalPosition(float))`(float finalPosition) ` Sets the rest position of the spring.                                               |
| ` `[SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce) | ` `[setStiffness](https://developer.android.com/reference/android/support/animation/SpringForce#setStiffness(float))`(float stiffness) ` Sets the stiffness of a spring.                                                                 |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/animation/SpringForce#)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() `                    | ||

## Constants

### DAMPING_RATIO_HIGH_BOUNCY

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

```
float DAMPING_RATIO_HIGH_BOUNCY
```

Damping ratio for a very bouncy spring. Note for under-damped springs (i.e. damping ratio \< 1), the lower the damping ratio, the more bouncy the spring.

<br />

Constant Value: 0.2  

### DAMPING_RATIO_LOW_BOUNCY

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

```
float DAMPING_RATIO_LOW_BOUNCY
```

Damping ratio for a spring with low bounciness. Note for under-damped springs (i.e. damping ratio \< 1), the lower the damping ratio, the higher the bounciness.

<br />

Constant Value: 0.75  

### DAMPING_RATIO_MEDIUM_BOUNCY

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

```
float DAMPING_RATIO_MEDIUM_BOUNCY
```

Damping ratio for a medium bouncy spring. This is also the default damping ratio for spring force. Note for under-damped springs (i.e. damping ratio \< 1), the lower the damping ratio, the more bouncy the spring.

<br />

Constant Value: 0.5  

### DAMPING_RATIO_NO_BOUNCY

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

```
float DAMPING_RATIO_NO_BOUNCY
```

Damping ratio for a spring with no bounciness. This damping ratio will create a critically damped spring that returns to equilibrium within the shortest amount of time without oscillating.

<br />

Constant Value: 1.0  

### STIFFNESS_HIGH

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

```
float STIFFNESS_HIGH
```

Stiffness constant for extremely stiff spring.

<br />

Constant Value: 10000.0  

### STIFFNESS_LOW

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

```
float STIFFNESS_LOW
```

Stiffness constant for a spring with low stiffness.

<br />

Constant Value: 200.0  

### STIFFNESS_MEDIUM

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

```
float STIFFNESS_MEDIUM
```

Stiffness constant for medium stiff spring. This is the default stiffness for spring force.

<br />

Constant Value: 1500.0  

### STIFFNESS_VERY_LOW

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

```
float STIFFNESS_VERY_LOW
```

Stiffness constant for a spring with very low stiffness.

<br />

Constant Value: 50.0

## Public constructors

### SpringForce

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

```
SpringForce ()
```

Creates a spring force. Note that final position of the spring must be set through[setFinalPosition(float)](https://developer.android.com/reference/android/support/animation/SpringForce#setFinalPosition(float))before the spring animation starts.

<br />

### SpringForce

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

```
SpringForce (float finalPosition)
```

Creates a spring with a given final rest position.

<br />

|                                        Parameters                                         ||
|-----------------|--------------------------------------------------------------------------|
| `finalPosition` | `float`: final position of the spring when it reaches equilibrium <br /> |

## Public methods

### getDampingRatio

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

```
float getDampingRatio ()
```

Returns the damping ratio of the spring.

<br />

|                   Returns                   ||
|---------|------------------------------------|
| `float` | damping ratio of the spring <br /> |

### getFinalPosition

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

```
float getFinalPosition ()
```

Returns the rest position of the spring.

<br />

|                   Returns                   ||
|---------|------------------------------------|
| `float` | rest position of the spring <br /> |

### getStiffness

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

```
float getStiffness ()
```

Gets the stiffness of the spring.

<br />

|                   Returns                   ||
|---------|------------------------------------|
| `float` | the stiffness of the spring <br /> |

### setDampingRatio

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

```
SpringForce setDampingRatio (float dampingRatio)
```

Spring damping ratio describes how oscillations in a system decay after a disturbance.

When damping ratio \> 1 (over-damped), the object will quickly return to the rest position without overshooting. If damping ratio equals to 1 (i.e. critically damped), the object will return to equilibrium within the shortest amount of time. When damping ratio is less than 1 (i.e. under-damped), the mass tends to overshoot, and return, and overshoot again. Without any damping (i.e. damping ratio = 0), the mass will oscillate forever.

Default damping ratio is[DAMPING_RATIO_MEDIUM_BOUNCY](https://developer.android.com/reference/android/support/animation/SpringForce#DAMPING_RATIO_MEDIUM_BOUNCY).

<br />

|                                                Parameters                                                ||
|----------------|------------------------------------------------------------------------------------------|
| `dampingRatio` | `float`: damping ratio of the spring, it should be non-negative Value is 0.0 or greater. |

|                                                                           Returns                                                                            ||
|----------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| [SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce) | the spring force that the given damping ratio is set on <br /> |

|                     Throws                      ||
|----------------------------|---------------------|
| `IllegalArgumentException` | if the is negative. |

### setFinalPosition

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

```
SpringForce setFinalPosition (float finalPosition)
```

Sets the rest position of the spring.

<br />

|                          Parameters                          ||
|-----------------|---------------------------------------------|
| `finalPosition` | `float`: rest position of the spring <br /> |

|                                                                            Returns                                                                            ||
|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce) | the spring force that the given final position is set on <br /> |

### setStiffness

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

```
SpringForce setStiffness (float stiffness)
```

Sets the stiffness of a spring. The more stiff a spring is, the more force it applies to the object attached when the spring is not at the final position. Default stiffness is[STIFFNESS_MEDIUM](https://developer.android.com/reference/android/support/animation/SpringForce#STIFFNESS_MEDIUM).

<br />

|                                         Parameters                                         ||
|-------------|-------------------------------------------------------------------------------|
| `stiffness` | `float`: non-negative stiffness constant of a spring Value is 0.0 or greater. |

|                                                                         Returns                                                                          ||
|----------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [SpringForce](https://developer.android.com/reference/android/support/animation/SpringForce) | the spring force that the given stiffness is set on <br /> |

|                                  Throws                                   ||
|----------------------------|-----------------------------------------------|
| `IllegalArgumentException` | if the given spring stiffness is not positive |

-

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