Skip to content

Commit cc18f3f

Browse files
committed
[M3][Chip] Add missing attributes to M3 chip styles
PiperOrigin-RevId: 409239837
1 parent 6517aa6 commit cc18f3f

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2021 The Android Open Source Project
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
https://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
19+
xmlns:tools="http://schemas.android.com/tools"
20+
android:viewportHeight="24.0"
21+
android:height="24dp"
22+
android:viewportWidth="24.0"
23+
android:width="24dp"
24+
tools:ignore="NewApi">
25+
<path
26+
android:fillColor="#000000"
27+
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
28+
</vector>

lib/java/com/google/android/material/chip/res/values/dimens.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
<dimen name="m3_chip_disabled_translation_z">-1dp</dimen>
2727
<dimen name="m3_chip_corner_size">8dp</dimen>
2828
<dimen name="m3_chip_elevated_elevation">1dp</dimen>
29+
<dimen name="m3_chip_icon_size">18dp</dimen>
2930

3031
</resources>

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,23 @@
149149
<!-- M3 Chips -->
150150

151151
<style name="Base.Widget.Material3.Chip" parent="Base.Widget.MaterialComponents.Chip">
152+
<item name="enforceTextAppearance">false</item>
152153
<item name="android:textAppearance">?attr/textAppearanceLabelLarge</item>
153154
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Material3.Chip</item>
154155
<item name="android:textColor">@color/m3_chip_text_color</item>
155-
<item name="chipIconTint">@color/m3_chip_text_color</item>
156156
<item name="closeIconTint">@color/m3_chip_text_color</item>
157157
<item name="chipStrokeColor">@color/m3_chip_stroke_color</item>
158158
<item name="chipSurfaceColor">?attr/colorSurface</item>
159159
<item name="chipBackgroundColor">@color/m3_chip_background_color</item>
160160
<item name="chipStrokeWidth">1dp</item>
161161
<item name="rippleColor">@color/m3_chip_ripple_color</item>
162162
<item name="checkedIcon">@drawable/ic_m3_chip_checked_circle</item>
163+
<item name="closeIcon">@drawable/ic_m3_chip_close</item>
164+
<item name="chipIconSize">@dimen/m3_chip_icon_size</item>
163165
<item name="android:stateListAnimator" tools:ignore="NewApi">
164166
@animator/m3_chip_state_list_anim
165167
</item>
168+
<item name="materialThemeOverlay">@style/ThemeOverlay.Material3.Chip</item>
166169
</style>
167170

168171
<!-- Style for Input Chip: for user-entered information.
@@ -209,7 +212,7 @@
209212
<!-- Style for input chips with system icons. For input chips with avatar
210213
style icons, use Widget.Material3.Chip.Input, instead. -->
211214
<style name="Widget.Material3.Chip.Input.Icon" parent="Widget.Material3.Chip.Input">
212-
<item name="chipIconSize">18dp</item>
215+
<item name="chipIconSize">@dimen/m3_chip_icon_size</item>
213216
<item name="iconStartPadding">4dp</item>
214217
</style>
215218

@@ -244,8 +247,6 @@
244247
<item name="checkedIconVisible">false</item>
245248
<item name="closeIconVisible">false</item>
246249

247-
<item name="enforceTextAppearance">false</item>
248-
249250
<item name="chipMinHeight">32dp</item>
250251

251252
<item name="chipStartPadding">8dp</item>
@@ -291,9 +292,7 @@
291292
<item name="checkedIconVisible">false</item>
292293
<item name="closeIconVisible">false</item>
293294

294-
<item name="enforceTextAppearance">false</item>
295295
<item name="android:textColor">@color/m3_chip_assist_text_color</item>
296-
<item name="chipIconTint">@color/m3_assist_chip_icon_tint_color</item>
297296

298297
<item name="chipMinHeight">32dp</item>
299298

@@ -305,6 +304,8 @@
305304
<item name="closeIconStartPadding">0dp</item>
306305
<item name="closeIconEndPadding">0dp</item>
307306
<item name="chipEndPadding">8dp</item>
307+
308+
<item name="materialThemeOverlay">@style/ThemeOverlay.Material3.Chip.Assist</item>
308309
</style>
309310

310311
<!-- Style for Assist Chip to be used against a background that needs
@@ -325,9 +326,7 @@
325326
<item name="chipIconVisible">false</item>
326327
<item name="closeIconVisible">false</item>
327328

328-
<item name="chipIconSize">18dp</item>
329329
<item name="checkedIcon">@drawable/ic_m3_chip_check</item>
330-
<item name="enforceTextAppearance">false</item>
331330

332331
<item name="chipMinHeight">32dp</item>
333332

@@ -367,4 +366,13 @@
367366
<item name="cornerSize">8dp</item>
368367
</style>
369368

369+
<style name="ThemeOverlay.Material3.Chip" parent="">
370+
<!-- To tint vector drawables used as leading icons -->
371+
<item name="colorControlNormal">@color/m3_chip_text_color</item>
372+
</style>
373+
374+
<style name="ThemeOverlay.Material3.Chip.Assist" parent="">
375+
<!-- To tint vector drawables used as leading icons -->
376+
<item name="colorControlNormal">@color/m3_assist_chip_icon_tint_color</item>
377+
</style>
370378
</resources>

0 commit comments

Comments
 (0)