Skip to content

Commit 4931d9b

Browse files
drchenraajkumars
authored andcommitted
[M3][Card] Update card dev doc with the new filled style and new assets
PiperOrigin-RevId: 399245794
1 parent 02704b4 commit 4931d9b

File tree

8 files changed

+41
-22
lines changed

8 files changed

+41
-22
lines changed

catalog/java/io/material/catalog/card/res/layout/cat_card_rich_media_demo_fragment.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
android:textAppearance="?attr/textAppearanceSubtitle1"/>
225225

226226
<com.google.android.material.card.MaterialCardView
227+
style="@style/Widget.Material3.CardView.Filled"
227228
android:layout_width="match_parent"
228229
android:layout_height="wrap_content"
229230
android:layout_margin="@dimen/mtrl_card_spacing"

docs/components/Card.md

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ more info.
4444

4545
### Making a card checkable
4646

47-
![Elevated card with a checked button and a light purple overlay; secondary
47+
![Outlined card with a checked button and a light purple overlay; secondary
4848
title and Action 1 and Action 2 buttons](assets/cards/cards_checked.png)
4949

5050
When a card is checked, it will show a checked icon and change its foreground
@@ -76,8 +76,8 @@ card.setOnLongClickListener {
7676

7777
### Making a card draggable
7878

79-
![Elevated card with a light grey overlay; secondary title and Action 1 and
80-
Action 2 buttons](assets/cards/cards_dragged.png)
79+
![Outlined card with a light grey overlay; secondary title and Action 1 and
80+
Action 2 buttons, being dragged](assets/cards/cards_dragged.png)
8181

8282
Cards have an `app:state_dragged` with foreground and elevation changes to
8383
convey motion. We recommend using
@@ -193,12 +193,13 @@ You can see an example
193193

194194
## Card
195195

196-
On mobile, an outlined [card’s](https://material.io/components/cards/#specs)
197-
default elevation is `0dp`, with a raised dragged elevation of `8dp`. The
198-
Material Android library also provides an elevated card style, which has an
199-
elevation of `1dp`, with a raised dragged elevation of `2dp`.
196+
On mobile, an outlined or a filled
197+
[card’s](https://material.io/components/cards/#specs) default elevation is
198+
`0dp`, with a raised dragged elevation of `8dp`. The Material Android library
199+
also provides an elevated card style, which has an elevation of `1dp`, with a
200+
raised dragged elevation of `2dp`.
200201

201-
![Elevated card with a secondary title and Action 1 and Action 2 buttons in
202+
![Outlined card with a secondary title and Action 1 and Action 2 buttons in
202203
purple](assets/cards/cards_basic.png)
203204

204205
### Card examples
@@ -211,7 +212,8 @@ API and source code:
211212

212213
**Note:** You don't need to specify a style tag as long as you are using a
213214
Material Components Theme. If not, set the style to
214-
`Widget.Material3.CardView.Outlined` or `Widget.Material3.CardView.Elevated`.
215+
`Widget.Material3.CardView.Outlined`, `Widget.Material3.CardView.Filled` or
216+
`Widget.Material3.CardView.Elevated`.
215217

216218
#### Outlined card
217219

@@ -299,6 +301,25 @@ Action 2 buttons in purple"](assets/cards/cards_outlined.png)
299301
</com.google.android.material.card.MaterialCardView>
300302
```
301303

304+
#### Filled card
305+
306+
The following example shows an filled card.
307+
308+
!["Filled card with a photo, title, a secondary title, text, and Action 1 and
309+
Action 2 buttons in purple"](assets/cards/cards_filled.png)
310+
311+
In the layout:
312+
313+
```xml
314+
<com.google.android.material.card.MaterialCardView
315+
...
316+
style="?attr/materialCardViewFilledStyle">
317+
318+
...
319+
320+
</com.google.android.material.card.MaterialCardView>
321+
```
322+
302323
#### Elevated card
303324

304325
The following example shows an elevated card.
@@ -323,17 +344,14 @@ In the layout:
323344
A card has a container and an optional thumbnail, header text, secondary text,
324345
media, supporting text, buttons and icons.
325346

326-
![card anatomy diagram](assets/cards/card-anatomy.png)
347+
![card anatomy diagram](assets/cards/card_anatomy.png)
327348

328349
1. Container
329-
2. Thumbnail
330-
3. Header text
331-
4. Secondary text
332-
5. Media
333-
6. Supporting text
334-
7. Buttons
335-
8. Icons
336-
9. Checked icon (not shown)
350+
2. Headline
351+
3. Subhead
352+
4. Supporting text
353+
5. Image
354+
6. Buttons
337355

338356
**Note:** All the optional elements of a card's content (with the exception of
339357
the checked icon) are implemented through the use of other views/components, as
@@ -343,12 +361,12 @@ shown in the [card examples](#card-examples) section.
343361

344362
Element | Attribute | Related method(s) | Default value
345363
-------------------- | ------------------------- | ------------------------------------------------------------------- | -------------
346-
**Color** | `app:cardBackgroundColor` | `setCardBackgroundColor`<br/>`getCardBackgroundColor` | `?attr/colorSurface`
364+
**Color** | `app:cardBackgroundColor` | `setCardBackgroundColor`<br/>`getCardBackgroundColor` | `?attr/colorSurface` or `?attr/colorSurfaceVariant` (filled style)
347365
**Foreground color** | `app:cardForegroundColor` | `setCardForegroundColor`<br/>`getCardForegroundColor` | `@android:color/transparent` (see all [states](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/card/res/color/m3_card_foreground_color.xml))
348366
**Stroke color** | `app:strokeColor` | `setStrokeColor`<br/>`getStrokeColor`<br/>`getStrokeColorStateList` | `?attr/colorOutline` (unchecked)<br/>`?attr/colorSecondary` (checked)
349-
**Stroke width** | `app:strokeWidth` | `setStrokeWidth`<br/>`getStrokeWidth` | `1dp` (outlined style)<br/>`0dp` (elevated style)
367+
**Stroke width** | `app:strokeWidth` | `setStrokeWidth`<br/>`getStrokeWidth` | `1dp` (outlined style)<br/>`0dp` (elevated or filled style)
350368
**Shape** | `app:shapeAppearance` | `setShapeAppearanceModel`<br/>`getShapeAppearanceModel` | `?attr/shapeAppearanceMediumComponent`
351-
**Elevation** | `app:cardElevation` | `setCardElevation`<br/>`setCardMaxElevation` | `0dp` (outlined style)<br/>`1dp` (elevated style)
369+
**Elevation** | `app:cardElevation` | `setCardElevation`<br/>`setCardMaxElevation` | `0dp` (outlined or filled style)<br/>`1dp` (elevated style)
352370
**Ripple color** | `app:rippleColor` | `setRippleColor`<br/>`setRippleColorResource`<br/>`getRippleColor` | `?attr/colorOnSurfaceVariant` at 20% opacity (see all [states](https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/card/res/color/m3_card_ripple_color.xml))
353371

354372
**Note:** We recommend that cards on mobile have `8dp` margins.
@@ -444,7 +462,7 @@ theme to all cards but does not affect other components:
444462
<item name="materialCardViewStyle">@style/Widget.App.CardView</item>
445463
</style>
446464

447-
<style name="Widget.App.CardView" parent="Widget.Material3.CardView.Outlined">
465+
<style name="Widget.App.CardView" parent="Widget.Material3.CardView.Elevated">
448466
<item name="materialThemeOverlay">@style/ThemeOverlay.App.Card</item>
449467
<item name="shapeAppearance">@style/ShapeAppearance.App.MediumComponent</item>
450468
</style>
-84.3 KB
Binary file not shown.
88.7 KB
Loading
-172 KB
Loading
111 KB
Loading
-18.6 KB
Loading
-223 KB
Loading

0 commit comments

Comments
 (0)