Skip to content

Commit bab907f

Browse files
hunterstichdsn5ft
authored andcommitted
[TopAppBar] Fix title fade mode collapsing title position errors.
Flinging the AppBarLayout can cause a negative number to be passed to CollapsingTextHelper#calculateOffsets, causing the collapsed title in fade mode to be positioned incorrectly. PiperOrigin-RevId: 374704850 (cherry picked from commit 0ef2e91)
1 parent 4e45c2c commit bab907f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static androidx.core.util.Preconditions.checkNotNull;
2020
import static android.text.Layout.Alignment.ALIGN_NORMAL;
2121
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
22+
import static java.lang.Math.max;
2223
import static java.lang.Math.min;
2324

2425
import android.animation.TimeInterpolator;
@@ -548,7 +549,7 @@ private void calculateOffsets(final float fraction) {
548549
} else {
549550
textBlendFraction = 1F;
550551
currentDrawX = collapsedDrawX;
551-
currentDrawY = collapsedDrawY - currentOffsetY;
552+
currentDrawY = collapsedDrawY - max(0, currentOffsetY);
552553

553554
setInterpolatedTextSize(collapsedTextSize);
554555
}

0 commit comments

Comments
 (0)