Skip to content

Commit 526ce8c

Browse files
drchendsn5ft
authored andcommitted
[TopAppBar] Fix margins not applied when collapsed and expanded text size and type face are the same
We missed to check if the available text width is changed when deciding if we should recreate the static text layout. Adds the check to fix the issue. Resolves #2459 PiperOrigin-RevId: 445941276
1 parent 8c775cb commit 526ce8c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,13 @@ private void calculateUsingTextSize(final float fraction, boolean forceRecalcula
10451045
if (availableWidth > 0) {
10461046
boolean textSizeChanged = currentTextSize != newTextSize;
10471047
boolean letterSpacingChanged = currentLetterSpacing != newLetterSpacing;
1048-
updateDrawText = textSizeChanged || letterSpacingChanged || boundsChanged || updateDrawText;
1048+
boolean availableWidthChanged = textLayout != null && availableWidth != textLayout.getWidth();
1049+
updateDrawText =
1050+
textSizeChanged
1051+
|| letterSpacingChanged
1052+
|| availableWidthChanged
1053+
|| boundsChanged
1054+
|| updateDrawText;
10491055
currentTextSize = newTextSize;
10501056
currentLetterSpacing = newLetterSpacing;
10511057
boundsChanged = false;

0 commit comments

Comments
 (0)