You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Material motion is a system to help create stylized and consistent animations across an app. Provided in the library are semantic easing and duration theme attributes, components that use themed motion for their built-in animations, and a set of transitions for navigational events or custom animations.
13
-
14
-
Before you can use the motion library, you need to add a dependency on the
15
-
Material Components for Android library (version `1.2.0` or later). For more
16
-
information, go to the
12
+
Material motion is a system to help create stylized and consistent animations
13
+
across an app. Provided in the library are semantic easing and duration theme
14
+
attributes, semantic spring theme attributes, components that use themed motion
15
+
for their built-in animations, and a set of transitions for
16
+
navigational events or custom animations.
17
+
18
+
The easing and duration motion system is available in version `1.6.0` or later.
19
+
The physics motion system is available in version `1.13.0` or later. For more
The Material motion system is backed by a limited number of easing and duration slots. These are the building blocks for creating any Material-styled animation. These slots are implemented as theme attributes, similar to color or shape attributes, and are used by all components in the library to create a unified motion feel.
29
+
The Material motion system is backed by a set of easing and duration slots and
30
+
a set of spring slots. These are the building blocks for creating any
31
+
Material-styled animation. These slots are implemented as theme attributes,
32
+
similar to color or shape attributes. They are used by components in the
33
+
library to create a unified motion feel and can be used by custom animations
34
+
to make motion feel cohesive across an entire app.
35
+
36
+
### Springs
37
+
38
+
The spring (or physics) motion system is a set of six opinionated spring
39
+
attributes intended to be used with the [Dynamic Animation AndroidX library](https://developer.android.com/develop/ui/views/animations/spring-animation#add-support-library).
40
+
A spring attribute is configured as a style made up of a damping and stiffness
41
+
value (see [MaterialSpring styleable](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/motion/res/values/attrs.xml)
42
+
for available properties and [spring styles](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/motion/res/values/styles.xml)
43
+
for examples). The damping ratio describes how rapidly spring oscillations
44
+
decay. Stiffness defines the strength of the spring. Learn more about how
45
+
spring animations work [here](https://developer.android.com/develop/ui/views/animations/spring-animation).
46
+
47
+
The spring system provides springs in three speeds - fast, slow, and default.
48
+
A speed is chosen based on the size of the component being animated or the
49
+
distance covered. Small component animations like switches should use the fast
50
+
spring, full screen animations or transitions should use the slow spring, and
51
+
everything in between should use the default spring.
52
+
53
+
Additionally, for each speed there are two types of springs - spatial and
54
+
effects. Spatial springs are used for animations that move something on
55
+
screen - like the x & y position of a View. Effects springs are used to animate
56
+
properties such as color or opacity where the property's value should not be
57
+
overshot (e.g. a background's alpha shouldn't bounce or oscillate above 100%).
**?attr/motionSpringFastSpatial** | `damping: 0.9, stiffness: 1400` | Spring for small components like switches and buttons.
64
+
**?attr/motionSpringFastEffects** | `damping: 1, stiffness: 3800` | Spring for small component effects like color and opacity.
65
+
**?attr/motionSpringSlowSpatial** | `damping: 0.9, stiffness: 300` | Spring for full screen animations.
66
+
**?attr/motionSpringSlowEffects** | `damping: 1, stiffness: 800` | Spring for full screen animation effects like color and opacity.
67
+
**?attr/motionSpringDefaultSpatial** | `damping: 0.9, stiffness: 700` | Spring for animations that partially cover the screen like a bottom sheet or nav drawer.
68
+
**?attr/motionSpringDefaultEffects** | `damping: 1, stiffness: 1600` | Spring for animation effects that partially cover the screen.
69
+
70
+
When building spring animations, a speed should be chosen based on the
71
+
animation's size or distance covered. Then, a spacial or effects type should be
72
+
chosen depending on the property being animated. For example, if animating a
73
+
button's shape and color when pressed, use two springs: a
74
+
`motionSpringFastSpatial` spring to animate the button's shape/size and a
75
+
`motionSpringFastEffects` spring to animate the button's color.
76
+
77
+
Spring attributes can be customized (or "themed") by overriding their value to
78
+
your own [MaterialSpring](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/motion/res/values/attrs.xml)
79
+
style.
80
+
81
+
#### Custom animations using the spring motion system
82
+
83
+
To create a spring animation, you'll need to declare a dependency on the
84
+
Dynamic Animation AndroidX library. Follow instructions for including the
Easing (aka interpolator) and duration theme attributes make up the curve
110
+
motion system. Easing is a curve which determines how long it takes an object
111
+
to start and stop moving. Duration determines the overall time of the animation.
112
+
These are paired together to define how motion moves and feels. Learn about
113
+
suggested pairings by reading through Material's
114
+
[Easing and duration guidance](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration).
28
115
29
-
Easing theme attributes define a set of curves that are used as [Interpolators](https://developer.android.com/reference/androidx/core/animation/Interpolator).
116
+
Material's curve system includes seven easing attributes
@@ -38,7 +127,10 @@ Attribute | Default value | Description
38
127
**?attr/motionEasingEmphasizedAccelerateInterpolator** | `cubic-bezier: 0.3, 0, 0.8, 0.15` | Easing used for common, M3-styled animations that exit the screen.
@@ -49,10 +141,8 @@ To customize an easing value, override any of the attributes in your app’s the
49
141
50
142
For more information on easing, see [Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration#569498ab-3e78-4e1a-bf59-c3fc7b1a187b).
51
143
52
-
### Duration
53
-
54
-
Duration attributes are a set of durations in milliseconds that can be used for
55
-
animations.
144
+
Material's curve system also includes 16 duration attributes to be paired
145
+
with an easing. The duration attributes include:
56
146
57
147
Attribute | Default value
58
148
-------------- | ------------------------
@@ -89,22 +179,14 @@ millisecond integer value.
89
179
90
180
For more information on duration, see [Applying easing and duration](https://m3.material.io/styles/motion/easing-and-duration/applying-easing-and-duration#569498ab-3e78-4e1a-bf59-c3fc7b1a187b).
91
181
92
-
### Path
93
-
94
-
Path attributes are values which control the behavior of animating elements.
**?attr/motionPath** | `linear` | An enum that controls the path along which animating elements move.<br/>`linear`: Elements move along a straight path from their current position to their new position. A linear path corresponds to a `null``PathMotion`.<br/>`arc`: Elements move along a curved/arced path. An arc path corresponds to a `MaterialArcMotion``PathMotion`.
#### Custom animations using the curve motion system
104
183
105
-
When implementing your own animations, use an easing and duration theme attribute so your animations tie in with animations used by Material components, bringing motion consistency across your app.
184
+
When implementing your own animations, use an easing and duration theme
185
+
attribute so your animations tie in with animations used by Material components,
186
+
bringing motion consistency across your app.
106
187
107
-
When creating animations in xml, set your animation's `interpolator` and `duration` properties to a Material motion theme attribute.
188
+
When creating animations in xml, set your animation's `interpolator` and
189
+
`duration` properties to a Material motion theme attribute.
108
190
109
191
```xml
110
192
<!-- res/anim/slide_in.xml –>
@@ -120,7 +202,8 @@ When creating animations in xml, set your animation's `interpolator` and `durati
120
202
<set/>
121
203
```
122
204
123
-
If creating animations in Java or Kotlin, Material provides a `MotionUtils` class to help facilitate loading `interpolator` and `duration` theme attributes.
205
+
If creating animations in Java or Kotlin, Material provides a `MotionUtils`
206
+
class to help facilitate loading `interpolator` and `duration` theme attributes.
124
207
125
208
```kt
126
209
val interpolator = MotionUtils.resolveThemeInterpolator(
@@ -138,7 +221,9 @@ val duration = MotionUtils.resolveThemeDuration(
138
221
139
222
## Transitions
140
223
141
-
Material provides a set of transition patterns that help users understand and navigate an app. For more information on the patterns and how to choose between them, check out the
224
+
Material provides a set of transition patterns that help users understand and
225
+
navigate an app. For more information on the patterns and how to choose between
0 commit comments