@@ -321,6 +321,16 @@ private void updatePaddingInternal() {
321321 (chipDrawable .getChipStartPadding ()
322322 + chipDrawable .getTextStartPadding ()
323323 + chipDrawable .calculateChipIconWidth ());
324+ if (insetBackgroundDrawable != null ) {
325+ Rect padding = new Rect ();
326+ Log .w ("mdc-chip" , "padding: " + padding .left + " " + padding .right );
327+ insetBackgroundDrawable .getPadding (padding );
328+ if (ViewCompat .getLayoutDirection (this ) == ViewCompat .LAYOUT_DIRECTION_RTL ) {
329+ paddingEnd += padding .right ;
330+ } else {
331+ paddingStart += padding .left ;
332+ }
333+ }
324334
325335 ViewCompat .setPaddingRelative (
326336 this , paddingStart , getPaddingTop (), paddingEnd , getPaddingBottom ());
@@ -404,7 +414,6 @@ public void setChipDrawable(@NonNull ChipDrawable drawable) {
404414 chipDrawable .setShouldDrawText (false );
405415 applyChipDrawable (chipDrawable );
406416 ensureAccessibleTouchTarget (minTouchTargetSize );
407- updateBackgroundDrawable ();
408417 }
409418 }
410419
@@ -667,7 +676,6 @@ public void setMaxWidth(@Px int maxWidth) {
667676 @ Override
668677 public void onChipDrawableSizeChange () {
669678 ensureAccessibleTouchTarget (minTouchTargetSize );
670- updateBackgroundDrawable ();
671679 requestLayout ();
672680 if (VERSION .SDK_INT >= VERSION_CODES .LOLLIPOP ) {
673681 invalidateOutline ();
@@ -2219,15 +2227,23 @@ public void setEnsureMinTouchTargetSize(boolean flag) {
22192227 public boolean ensureAccessibleTouchTarget (@ Dimension int minTargetPx ) {
22202228 minTouchTargetSize = minTargetPx ;
22212229 if (!shouldEnsureMinTouchTargetSize ()) {
2222- removeBackgroundInset ();
2230+ if (insetBackgroundDrawable != null ) {
2231+ removeBackgroundInset ();
2232+ } else {
2233+ updateBackgroundDrawable ();
2234+ }
22232235 return false ;
22242236 }
22252237
22262238 int deltaHeight = Math .max (0 , minTargetPx - chipDrawable .getIntrinsicHeight ());
22272239 int deltaWidth = Math .max (0 , minTargetPx - chipDrawable .getIntrinsicWidth ());
22282240
22292241 if (deltaWidth <= 0 && deltaHeight <= 0 ) {
2230- removeBackgroundInset ();
2242+ if (insetBackgroundDrawable != null ) {
2243+ removeBackgroundInset ();
2244+ } else {
2245+ updateBackgroundDrawable ();
2246+ }
22312247 return false ;
22322248 }
22332249
@@ -2241,6 +2257,7 @@ public boolean ensureAccessibleTouchTarget(@Dimension int minTargetPx) {
22412257 && padding .bottom == deltaY
22422258 && padding .left == deltaX
22432259 && padding .right == deltaX ) {
2260+ updateBackgroundDrawable ();
22442261 return true ;
22452262 }
22462263 }
@@ -2256,6 +2273,7 @@ public boolean ensureAccessibleTouchTarget(@Dimension int minTargetPx) {
22562273 setMinWidth (minTargetPx );
22572274 }
22582275 insetChipBackgroundDrawable (deltaX , deltaY , deltaX , deltaY );
2276+ updateBackgroundDrawable ();
22592277 return true ;
22602278 }
22612279
0 commit comments