Skip to content

Commit 788866e

Browse files
committedApr 15, 2022
[Chip] Fix chip layout not updated when programmatically setting text size
We didn't forward Chip.setTextSize() call properly to ChipDrawable.setTextSize(). Fixes this by properly overriding the method. Resolves #1855 PiperOrigin-RevId: 442056225
1 parent e74baff commit 788866e

File tree

1 file changed

+11
-0
lines changed
  • lib/java/com/google/android/material/chip

1 file changed

+11
-0
lines changed
 

‎lib/java/com/google/android/material/chip/Chip.java

+11
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import android.text.TextUtils.TruncateAt;
4545
import android.util.AttributeSet;
4646
import android.util.Log;
47+
import android.util.TypedValue;
4748
import android.view.Gravity;
4849
import android.view.KeyEvent;
4950
import android.view.MotionEvent;
@@ -1366,6 +1367,16 @@ public void setTextAppearance(int resId) {
13661367
updateTextPaintDrawState();
13671368
}
13681369

1370+
@Override
1371+
public void setTextSize(int unit, float size) {
1372+
super.setTextSize(unit, size);
1373+
if (chipDrawable != null) {
1374+
chipDrawable.setTextSize(
1375+
TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics()));
1376+
}
1377+
updateTextPaintDrawState();
1378+
}
1379+
13691380
private void updateTextPaintDrawState() {
13701381
TextPaint textPaint = getPaint();
13711382
if (chipDrawable != null) {

0 commit comments

Comments
 (0)
Please sign in to comment.