Skip to content

Commit

Permalink
[TopAppBar] Fix title fade mode collapsing title position errors.
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
hunterstich authored and dsn5ft committed Jun 2, 2021
1 parent 4e45c2c commit bab907f
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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;
Expand Down Expand Up @@ -548,7 +549,7 @@ private void calculateOffsets(final float fraction) {
} else {
textBlendFraction = 1F;
currentDrawX = collapsedDrawX;
currentDrawY = collapsedDrawY - currentOffsetY;
currentDrawY = collapsedDrawY - max(0, currentOffsetY);

setInterpolatedTextSize(collapsedTextSize);
}
Expand Down

0 comments on commit bab907f

Please sign in to comment.