@@ -182,6 +182,7 @@ public class ChipDrawable extends MaterialShapeDrawable
182182 @ Nullable private Drawable chipIcon ;
183183 @ Nullable private ColorStateList chipIconTint ;
184184 private float chipIconSize ;
185+ private boolean hasChipIconTint ;
185186
186187 // Close icon
187188 private boolean closeIconVisible ;
@@ -378,7 +379,10 @@ private void loadFromAttributes(
378379 setChipIconVisible (a .getBoolean (R .styleable .Chip_chipIconEnabled , false ));
379380 }
380381 setChipIcon (MaterialResources .getDrawable (context , a , R .styleable .Chip_chipIcon ));
381- setChipIconTint (MaterialResources .getColorStateList (context , a , R .styleable .Chip_chipIconTint ));
382+ if (a .hasValue (R .styleable .Chip_chipIconTint )) {
383+ setChipIconTint (
384+ MaterialResources .getColorStateList (context , a , R .styleable .Chip_chipIconTint ));
385+ }
382386 setChipIconSize (a .getDimension (R .styleable .Chip_chipIconSize , 0f ));
383387
384388 setCloseIconVisible (a .getBoolean (R .styleable .Chip_closeIconVisible , false ));
@@ -1265,25 +1269,26 @@ private void unapplyChildDrawable(@Nullable Drawable drawable) {
12651269
12661270 /** Note: This should not change the size of the drawable. */
12671271 private void applyChildDrawable (@ Nullable Drawable drawable ) {
1268- if (drawable != null ) {
1269- drawable .setCallback (this );
1270- DrawableCompat .setLayoutDirection (drawable , DrawableCompat .getLayoutDirection (this ));
1271- drawable .setLevel (getLevel ());
1272- drawable .setVisible (isVisible (), false );
1273-
1274- if (drawable == closeIcon ) {
1275- if (drawable .isStateful ()) {
1276- drawable .setState (getCloseIconState ());
1277- }
1278- DrawableCompat .setTintList (drawable , closeIconTint );
1279- } else {
1280- if (drawable .isStateful ()) {
1281- drawable .setState (getState ());
1282- }
1283- if (drawable == chipIcon ) {
1284- DrawableCompat .setTintList (chipIcon , chipIconTint );
1285- }
1272+ if (drawable == null ) {
1273+ return ;
1274+ }
1275+ drawable .setCallback (this );
1276+ DrawableCompat .setLayoutDirection (drawable , DrawableCompat .getLayoutDirection (this ));
1277+ drawable .setLevel (getLevel ());
1278+ drawable .setVisible (isVisible (), false );
1279+
1280+ if (drawable == closeIcon ) {
1281+ if (drawable .isStateful ()) {
1282+ drawable .setState (getCloseIconState ());
12861283 }
1284+ DrawableCompat .setTintList (drawable , closeIconTint );
1285+ return ;
1286+ }
1287+ if (drawable .isStateful ()) {
1288+ drawable .setState (getState ());
1289+ }
1290+ if (drawable == chipIcon && hasChipIconTint ) {
1291+ DrawableCompat .setTintList (chipIcon , chipIconTint );
12871292 }
12881293 }
12891294
@@ -1684,9 +1689,9 @@ public void setChipIconTintResource(@ColorRes int id) {
16841689 * @attr ref com.google.android.material.R.styleable#Chip_chipIconTint
16851690 */
16861691 public void setChipIconTint (@ Nullable ColorStateList chipIconTint ) {
1692+ hasChipIconTint = true ;
16871693 if (this .chipIconTint != chipIconTint ) {
16881694 this .chipIconTint = chipIconTint ;
1689-
16901695 if (showsChipIcon ()) {
16911696 DrawableCompat .setTintList (chipIcon , chipIconTint );
16921697 }
0 commit comments