# MotionUtils

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/motion/MotionUtils.java)

*** ** * ** ***


```
public class MotionUtils
```

<br />

*** ** * ** ***

A utility class for motion system functions.

## Summary

| ### Public methods |
|---|---|
| `static int` | `https://developer.android.com/reference/com/google/android/material/motion/MotionUtils#resolveThemeDuration(Context,int,int)( Context context, int attrResId, int defaultDuration )` Resolve a duration from a material duration theme attribute. |
| `static TimeInterpolator` | `https://developer.android.com/reference/com/google/android/material/motion/MotionUtils#resolveThemeInterpolator(Context,int,TimeInterpolator)( Context context, int attrResId, TimeInterpolator defaultInterpolator )` Load an interpolator from a material easing theme attribute. |
| `static SpringForce` | `https://developer.android.com/reference/com/google/android/material/motion/MotionUtils#resolveThemeSpringForce(Context,int,int)(Context context, int attrResId, int defStyleRes)` Resolve a SpringForce object from a Material spring theme attribute. |

## Public methods

### resolveThemeDuration

```
public static int resolveThemeDuration(
    Context context,
    int attrResId,
    int defaultDuration
)
```

Resolve a duration from a material duration theme attribute.

| Parameters |
|---|---|
| `Context context` | the context from where the theme attribute will be resolved. |
| `int attrResId` | the `motionDuration*` theme attribute to resolve |
| `int defaultDuration` | the duration to be returned if unable to resolve `attrResId` |

| Returns |
|---|---|
| `int` | the resolved `int` duration which `attrResId` points to or the ` defaultDuration` if resolution was unsuccessful. |

### resolveThemeInterpolator

```
public static TimeInterpolator resolveThemeInterpolator(
    Context context,
    int attrResId,
    TimeInterpolator defaultInterpolator
)
```

Load an interpolator from a material easing theme attribute.

| Parameters |
|---|---|
| `Context context` | context from where the theme attribute will be resolved |
| `int attrResId` | the `motionEasing*` theme attribute to resolve |
| `TimeInterpolator defaultInterpolator` | the interpolator to be returned if unable to resolve ` attrResId`. |

| Returns |
|---|---|
| `TimeInterpolator` | the resolved TimeInterpolator which `attrResId` points to or the ` defaultInterpolator` if resolution was unsuccessful. |

### resolveThemeSpringForce

```
public static SpringForce resolveThemeSpringForce(Context context, int attrResId, int defStyleRes)
```

Resolve a SpringForce object from a Material spring theme attribute.

| Parameters |
|---|---|
| `Context context` | the context from where the theme attribute will be resolved |
| `int attrResId` | the `motionSpring*` theme attribute to resolve into a SpringForce object |
| `int defStyleRes` | a `MaterialSpring` style to load if attrResId cannot be resolved |

| Returns |
|---|---|
| `SpringForce` | a SpringForce object configured using the stiffness and damping from the resolved Material spring attribute |