Skip to content

Commit 1d50ed7

Browse files
drchenpaulfthomas
authored andcommitted
[TopAppBar][TextField] Remove unneeded logic
After letter spacing is correctly set in CollapsingTextHelper.calculateUsingTextSize(), we no longer need to set letter spacing separately for collapsed and expanded titles. Also this enhances the logic by using textPaint consistently in CollapsingTextHelper.calculateBaseOffsets(), which was not the case before the change. (We got text height from textPaint and text width from tmpPaint.) PiperOrigin-RevId: 410888232
1 parent 2d337c5 commit 1d50ed7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/java/com/google/android/material/internal/CollapsingTextHelper.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,7 @@ private void calculateBaseOffsets(boolean forceRecalculate) {
712712
TextUtils.ellipsize(textToDraw, textPaint, textLayout.getWidth(), TruncateAt.END);
713713
}
714714
if (textToDrawCollapsed != null) {
715-
getTextPaintCollapsed(tmpPaint);
716-
collapsedTextWidth = measureTextWidth(tmpPaint, textToDrawCollapsed);
715+
collapsedTextWidth = measureTextWidth(textPaint, textToDrawCollapsed);
717716
} else {
718717
collapsedTextWidth = 0;
719718
}
@@ -755,8 +754,7 @@ private void calculateBaseOffsets(boolean forceRecalculate) {
755754
if (textLayout != null && maxLines > 1) {
756755
expandedTextWidth = textLayout.getWidth();
757756
} else if (textToDraw != null) {
758-
getTextPaintExpanded(tmpPaint);
759-
expandedTextWidth = measureTextWidth(tmpPaint, textToDraw);
757+
expandedTextWidth = measureTextWidth(textPaint, textToDraw);
760758
}
761759
expandedLineCount = textLayout != null ? textLayout.getLineCount() : 0;
762760

0 commit comments

Comments
 (0)