Skip to content

Commit 93ae730

Browse files
imhappidrchen
authored andcommitted
[Lists] Add styles and theme overlays for material icon buttons inside lists
PiperOrigin-RevId: 834834478
1 parent 6310274 commit 93ae730

File tree

5 files changed

+95
-15
lines changed

5 files changed

+95
-15
lines changed

catalog/java/io/material/catalog/listitem/res/layout/cat_list_item_segmented_viewholder.xml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,17 @@
7575
android:layout_height="match_parent"
7676
android:layout_width="wrap_content">
7777
<com.google.android.material.button.MaterialButton
78-
style="?attr/materialIconButtonFilledStyle"
79-
android:insetLeft="0dp"
80-
android:insetRight="0dp"
78+
style="?attr/materialIconButtonFilledTonalStyle"
8179
android:layout_height="match_parent"
8280
android:layout_width="64dp"
8381
android:layout_marginEnd="2dp"
8482
android:layout_marginStart="2dp"
85-
app:icon="@drawable/ic_add_24px"
86-
app:iconGravity="textStart" />
83+
app:icon="@drawable/ic_add_24px" />
8784
<com.google.android.material.button.MaterialButton
88-
style="?attr/materialIconButtonFilledStyle"
89-
android:insetLeft="0dp"
90-
android:insetRight="0dp"
91-
android:layout_height="match_parent"
92-
android:layout_width="64dp"
93-
android:layout_marginEnd="2dp"
94-
app:icon="@drawable/ic_star_icon_checkable_24px"
95-
app:iconGravity="textStart" />
85+
style="?attr/materialIconButtonFilledStyle"
86+
android:layout_height="match_parent"
87+
android:layout_width="64dp"
88+
android:layout_marginEnd="2dp"
89+
app:icon="@drawable/ic_star_icon_checkable_24px" />
9690
</com.google.android.material.listitem.ListItemRevealLayout>
9791
</com.google.android.material.listitem.ListItemLayout>

lib/java/com/google/android/material/dialog/res/values/themes_base.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
<item name="materialSearchBarStyle">@style/Widget.Material3Expressive.SearchBar</item>
4242

43+
<item name="listItemRevealLayoutStyle">@style/Widget.Material3Expressive.ListItemRevealLayout</item>
44+
4345
<!--
4446
Default as primary container FABs. Unlisted FAB style attributes are not updated in Material3Expressive.
4547
Please use the corresponding themeoverlay for other color variants via materialThemeOverlay.
@@ -99,6 +101,8 @@
99101

100102
<item name="materialSearchBarStyle">@style/Widget.Material3Expressive.SearchBar</item>
101103

104+
<item name="listItemRevealLayoutStyle">@style/Widget.Material3Expressive.ListItemRevealLayout</item>
105+
102106
<!--
103107
Default as primary container FABs. Unlisted FAB style attributes are not updated in Material3Expressive.
104108
Please use the corresponding themeoverlay for other color variants via materialThemeOverlay.

lib/java/com/google/android/material/listitem/res-public/values/public.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
<public name="Widget.Material3.ListItemCardView" type="style"/>
2828
<public name="Widget.Material3.ListItemCardView.Segmented" type="style"/>
2929
<public name="Widget.Material3.ListItemRevealLayout" type="style"/>
30+
<public name="Widget.Material3Expressive.ListItemRevealLayout" type="style"/>
31+
<public name="ThemeOverlay.Material3.ListItemRevealLayout" type="style"/>
32+
<public name="ThemeOverlay.Material3Expressive.ListItemRevealLayout" type="style"/>
3033
<public name="ShapeAppearance.Material3.ListItem.First" type="style"/>
3134
<public name="ShapeAppearance.Material3.ListItem.Middle" type="style"/>
3235
<public name="ShapeAppearance.Material3.ListItem.Last" type="style"/>
@@ -42,6 +45,14 @@
4245
<public name="Widget.Material3.Checkbox.ListItem" type="style"/>
4346
<public name="Widget.Material3.Switch.ListItem" type="style"/>
4447
<public name="Widget.Material3.RadioButton.ListItem" type="style"/>
48+
<public name="Widget.Material3.Button.IconButton.ListItemRevealLayout" type="style"/>
49+
<public name="Widget.Material3.Button.IconButton.Filled.ListItemRevealLayout" type="style"/>
50+
<public name="Widget.Material3.Button.IconButton.Filled.Tonal.ListItemRevealLayout" type="style"/>
51+
<public name="Widget.Material3.Button.IconButton.Outlined.ListItemRevealLayout" type="style"/>
52+
<public name="Widget.Material3Expressive.Button.IconButton.ListItemRevealLayout" type="style"/>
53+
<public name="Widget.Material3Expressive.Button.IconButton.Filled.ListItemRevealLayout" type="style"/>
54+
<public name="Widget.Material3Expressive.Button.IconButton.Tonal.ListItemRevealLayout" type="style"/>
55+
<public name="Widget.Material3Expressive.Button.IconButton.Outlined.ListItemRevealLayout" type="style"/>
4556

4657
<public name="listItemShapeAppearanceSingle" type="attr"/>
4758
<public name="listItemShapeAppearanceFirst" type="attr"/>

lib/java/com/google/android/material/listitem/res/values/styles.xml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,80 @@
3737
<item name="swipeToPrimaryActionEnabled">false</item>
3838
</style>
3939

40+
<style name="Widget.Material3.ListItemCardView.Segmented">
41+
<item name="cardBackgroundColor">@color/m3_segmented_list_item_background_color_selector</item>
42+
</style>
43+
4044
<style name="Widget.Material3.ListItemRevealLayout" parent="">
4145
<item name="enforceMaterialTheme">true</item>
46+
<item name="materialThemeOverlay">@style/ThemeOverlay.Material3.ListItemRevealLayout</item>
4247
<item name="minChildWidth">@dimen/m3_list_reveal_min_child_width</item>
4348
</style>
4449

45-
<style name="Widget.Material3.ListItemCardView.Segmented">
46-
<item name="cardBackgroundColor">@color/m3_segmented_list_item_background_color_selector</item>
50+
<style name="Widget.Material3Expressive.ListItemRevealLayout" parent="Widget.Material3.ListItemRevealLayout">
51+
<item name="materialThemeOverlay">@style/ThemeOverlay.Material3Expressive.ListItemRevealLayout</item>
52+
</style>
53+
54+
<style name="ThemeOverlay.Material3.ListItemRevealLayout">
55+
<item name="materialIconButtonStyle">@style/Widget.Material3.Button.IconButton.ListItemRevealLayout</item>
56+
<item name="materialIconButtonFilledStyle">@style/Widget.Material3.Button.IconButton.Filled.ListItemRevealLayout</item>
57+
<item name="materialIconButtonFilledTonalStyle">@style/Widget.Material3.Button.IconButton.Filled.Tonal.ListItemRevealLayout</item>
58+
<item name="materialIconButtonOutlinedStyle">@style/Widget.Material3.Button.IconButton.Outlined.ListItemRevealLayout</item>
59+
</style>
60+
61+
<style name="ThemeOverlay.Material3Expressive.ListItemRevealLayout">
62+
<item name="materialIconButtonStyle">@style/Widget.Material3Expressive.Button.IconButton.ListItemRevealLayout</item>
63+
<item name="materialIconButtonFilledStyle">@style/Widget.Material3Expressive.Button.IconButton.Filled.ListItemRevealLayout</item>
64+
<item name="materialIconButtonFilledTonalStyle">@style/Widget.Material3Expressive.Button.IconButton.Tonal.ListItemRevealLayout</item>
65+
<item name="materialIconButtonOutlinedStyle">@style/Widget.Material3Expressive.Button.IconButton.Outlined.ListItemRevealLayout</item>
66+
</style>
67+
68+
<style name="Widget.Material3.Button.IconButton.ListItemRevealLayout">
69+
<item name="iconGravity">textStart</item>
70+
<item name="android:insetLeft">0dp</item>
71+
<item name="android:insetRight">0dp</item>
72+
</style>
73+
74+
<style name="Widget.Material3.Button.IconButton.Filled.ListItemRevealLayout">
75+
<item name="iconGravity">textStart</item>
76+
<item name="android:insetLeft">0dp</item>
77+
<item name="android:insetRight">0dp</item>
78+
</style>
79+
80+
<style name="Widget.Material3.Button.IconButton.Filled.Tonal.ListItemRevealLayout">
81+
<item name="iconGravity">textStart</item>
82+
<item name="android:insetLeft">0dp</item>
83+
<item name="android:insetRight">0dp</item>
84+
</style>
85+
86+
<style name="Widget.Material3.Button.IconButton.Outlined.ListItemRevealLayout">
87+
<item name="iconGravity">textStart</item>
88+
<item name="android:insetLeft">0dp</item>
89+
<item name="android:insetRight">0dp</item>
90+
</style>
91+
92+
<style name="Widget.Material3Expressive.Button.IconButton.ListItemRevealLayout">
93+
<item name="iconGravity">textStart</item>
94+
<item name="android:insetLeft">0dp</item>
95+
<item name="android:insetRight">0dp</item>
96+
</style>
97+
98+
<style name="Widget.Material3Expressive.Button.IconButton.Filled.ListItemRevealLayout">
99+
<item name="iconGravity">textStart</item>
100+
<item name="android:insetLeft">0dp</item>
101+
<item name="android:insetRight">0dp</item>
102+
</style>
103+
104+
<style name="Widget.Material3Expressive.Button.IconButton.Tonal.ListItemRevealLayout">
105+
<item name="iconGravity">textStart</item>
106+
<item name="android:insetLeft">0dp</item>
107+
<item name="android:insetRight">0dp</item>
108+
</style>
109+
110+
<style name="Widget.Material3Expressive.Button.IconButton.Outlined.ListItemRevealLayout">
111+
<item name="iconGravity">textStart</item>
112+
<item name="android:insetLeft">0dp</item>
113+
<item name="android:insetRight">0dp</item>
47114
</style>
48115

49116
<style name="ShapeAppearance.Material3.ListItem.First" parent="">

lib/java/com/google/android/material/theme/res/values/themes_base.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
<item name="materialSearchBarStyle">@style/Widget.Material3Expressive.SearchBar</item>
4242

43+
<item name="listItemRevealLayoutStyle">@style/Widget.Material3Expressive.ListItemRevealLayout</item>
44+
4345
<!--
4446
Default as primary container FABs. Unlisted FAB style attributes are not updated in Material3Expressive.
4547
Please use the corresponding themeoverlay for other color variants via materialThemeOverlay.
@@ -106,6 +108,8 @@
106108

107109
<item name="materialSearchBarStyle">@style/Widget.Material3Expressive.SearchBar</item>
108110

111+
<item name="listItemRevealLayoutStyle">@style/Widget.Material3Expressive.ListItemRevealLayout</item>
112+
109113
<!--
110114
Default as primary container FABs. Unlisted FAB style attributes are not updated in Material3Expressive.
111115
Please use the corresponding themeoverlay for other color varaints via materialThemeOverlay.

0 commit comments

Comments
 (0)