[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
This commit is contained in:
hunterstich 2021-05-19 12:33:01 -07:00 committed by pekingme
parent 6e7be6070c
commit 0ef2e910ce

View File

@ -19,6 +19,7 @@ package com.google.android.material.internal;
import static androidx.core.util.Preconditions.checkNotNull;
import static android.text.Layout.Alignment.ALIGN_NORMAL;
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
import static java.lang.Math.max;
import static java.lang.Math.min;
import android.animation.TimeInterpolator;
@ -548,7 +549,7 @@ public final class CollapsingTextHelper {
} else {
textBlendFraction = 1F;
currentDrawX = collapsedDrawX;
currentDrawY = collapsedDrawY - currentOffsetY;
currentDrawY = collapsedDrawY - max(0, currentOffsetY);
setInterpolatedTextSize(collapsedTextSize);
}