Skip to content

Commit 2bc1a2f

Browse files
dsn5ftafohrman
authored andcommitted
[CollapsingToolbarLayout] Fix issues related to rotating multiline collapsing toolbars
PiperOrigin-RevId: 636597914
1 parent 60a525a commit 2bc1a2f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/java/com/google/android/material/appbar/CollapsingToolbarLayout.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,13 +599,15 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
599599
updateTextBounds(0, 0, getMeasuredWidth(), getMeasuredHeight(), /* forceRecalculate= */ true);
600600

601601
int lineCount = collapsingTextHelper.getExpandedLineCount();
602-
if (lineCount > 1) {
602+
if (lineCount > 1 && collapsingTextHelper.getExpansionFraction() == 0f) {
603603
// Add extra height based on the amount of height beyond the first line of title text.
604604
int expandedTextHeight = Math.round(collapsingTextHelper.getExpandedTextFullHeight());
605605
extraMultilineHeight = expandedTextHeight * (lineCount - 1);
606606
int newHeight = getMeasuredHeight() + extraMultilineHeight;
607607
heightMeasureSpec = MeasureSpec.makeMeasureSpec(newHeight, MeasureSpec.EXACTLY);
608608
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
609+
} else {
610+
extraMultilineHeight = 0;
609611
}
610612
}
611613

0 commit comments

Comments
 (0)