Skip to content

Commit 708c50f

Browse files
afohrmanpekingme
authored andcommitted
[Docs] Updated shape theming documentation.
PiperOrigin-RevId: 352876262
1 parent 11169ce commit 708c50f

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

docs/theming/Shape.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ path: /theming/shape/
1111

1212
Material Design encourages brand expression through shapes. The Material
1313
Components library offers a `shape` library that can be used to create
14-
non-standard shapes using `MaterialShapeDrawable`s, a `Drawable` that can draw
14+
non-standard shapes using a `MaterialShapeDrawable`, a `Drawable` that can draw
1515
custom shapes while taking shadows, elevation, scale and color into account.
1616

1717
On top of the shape library, the Material Components library provides a
@@ -65,7 +65,10 @@ Attribute Name | Description | Default Value
6565

6666
Aside from defining these attributes in your theme, you likely will not need to
6767
reference these attributes at all; the widget styles are already mapped to the
68-
appropriate theme attribute to create a seamless shape theming experience.
68+
appropriate theme attribute to create a seamless shape theming experience. To
69+
change individual shapes throughout your app, you should use the
70+
[shapeAppearance and shapeAppearanceOverlay](#shapeappearance-and-shapeappearanceoverlay-attributes)
71+
attributes rather than redefining these theme level attributes.
6972

7073
## Usage
7174

@@ -127,9 +130,9 @@ your theme. This will allow
127130
[components that support shape theming](#supported-components) to read in the
128131
customized values and change their shapes accordingly.
129132

130-
Let's say you want to change the corners in your app to cut corners. To
131-
accomplish this, define the shape theme attributes to point to custom style
132-
references that contain shape values:
133+
Let's say you want to change the small and medium components' corners in your
134+
app to cut corners. To accomplish this, define the shape theme attributes to
135+
point to custom style references that contain shape values:
133136

134137
```xml
135138
<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light">
@@ -169,8 +172,8 @@ style themselves according to the themed shape values.
169172

170173
#### Theme-wide component overrides
171174

172-
You can change a component's shape across the entire app by overriding the
173-
component and defining a custom `shapeAppearanceOverlay`.
175+
You can change a component's shape across the entire app by defining a custom
176+
`shapeAppearanceOverlay` in the component's style.
174177

175178
Let's say you wanted to modify `MaterialCardView` so that it uses 16dp rounded
176179
corners across the entire app. All you'd have to do is define your own card
@@ -192,7 +195,7 @@ And define `ShapeAppearanceOverlay.MyApp.MaterialCardView` as follows:
192195
</style>
193196
```
194197

195-
Then make sure to define the custom component style in your theme:
198+
Then make sure to set component's style in your theme to your custom style:
196199

197200
```xml
198201
<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light">
@@ -212,7 +215,8 @@ that should have 16dp cut corners. To change that card's `cornerFamily`, you can
212215
set the `shapeAppearanceOverlay` attribute on the card in your layout.
213216

214217
Define a custom `shapeAppearanceOverlay` style with just the attribute you want
215-
to overlay on top of the existing `shapeAppearance`:
218+
to overlay on top of the existing `shapeAppearance`. In this case, you would set
219+
`cornerFamily` to `cut`:
216220

217221
```xml
218222
<style name="ShapeAppearanceOverlay.MyApp.MaterialCardView.Cut" parent="">
@@ -238,11 +242,13 @@ Then, set the card's `shapeAppearanceOverlay` attribute to that
238242
</com.google.android.material.card.MaterialCardView>
239243
```
240244

241-
The card should now have 16dp cut corners.
245+
The `cornerFamily` attribute set in the `shapeAppearanceOverlay` will override
246+
the `cornerFamily` set in the card's `shapeAppearance`, so the card should now
247+
have 16dp cut corners instead of 16dp rounded corners.
242248

243249
#### Supported Components
244250

245-
The following is a list of Material components that support shape theming.
251+
The following are some Material components that support shape theming.
246252
Components that support shape theming have a `shapeAppearance` attribute, a
247253
`shapeAppearanceOverlay` attribute, and are backed by a `MaterialShapeDrawable`.
248254

0 commit comments

Comments
 (0)