Skip to content

Commit

Permalink
[Chip] Fix chip layout not updated when programmatically setting text…
Browse files Browse the repository at this point in the history
… size

We didn't forward Chip.setTextSize() call properly to ChipDrawable.setTextSize(). Fixes this by properly overriding the method.

Resolves #1855

PiperOrigin-RevId: 442056225
  • Loading branch information
drchen committed Apr 15, 2022
1 parent e74baff commit 788866e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/java/com/google/android/material/chip/Chip.java
Expand Up @@ -44,6 +44,7 @@
import android.text.TextUtils.TruncateAt;
import android.util.AttributeSet;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
Expand Down Expand Up @@ -1366,6 +1367,16 @@ public void setTextAppearance(int resId) {
updateTextPaintDrawState();
}

@Override
public void setTextSize(int unit, float size) {
super.setTextSize(unit, size);
if (chipDrawable != null) {
chipDrawable.setTextSize(
TypedValue.applyDimension(unit, size, getResources().getDisplayMetrics()));
}
updateTextPaintDrawState();
}

private void updateTextPaintDrawState() {
TextPaint textPaint = getPaint();
if (chipDrawable != null) {
Expand Down

0 comments on commit 788866e

Please sign in to comment.