Skip to content

Commit 7674e12

Browse files
pubiqqpaulfthomas
authored andcommitted
[CollapsingToolbarLayout] Fix text shadow fading when transitioning between expanded and collapsed states
Resolves #3641 GIT_ORIGIN_REV_ID=7243f7a2f09b04caceec488443b1652a8ffef961 PiperOrigin-RevId: 578838845
1 parent 1756f23 commit 7674e12

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,14 @@ private void calculateOffsets(final float fraction) {
672672
int textAlpha = (int) (calculateFadeModeTextAlpha(fraction) * originalAlpha);
673673

674674
textPaint.setAlpha(textAlpha);
675+
// Workaround for API 31(+). Applying the shadow color for the painted text.
676+
if (VERSION.SDK_INT >= VERSION_CODES.S) {
677+
textPaint.setShadowLayer(
678+
currentShadowRadius,
679+
currentShadowDx,
680+
currentShadowDy,
681+
MaterialColors.compositeARGBWithAlpha(currentShadowColor, textPaint.getAlpha()));
682+
}
675683
}
676684

677685
ViewCompat.postInvalidateOnAnimation(view);

0 commit comments

Comments
 (0)