From 6f28838185b4696fcc42d08fc855525de2b8d0ea Mon Sep 17 00:00:00 2001 From: dniz Date: Tue, 29 Jun 2021 06:40:02 -0700 Subject: [PATCH] [CollapsingToolbarLayout] Fixed multiline RTL collapsed title text position PiperOrigin-RevId: 382073266 --- .../android/material/internal/CollapsingTextHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/java/com/google/android/material/internal/CollapsingTextHelper.java b/lib/java/com/google/android/material/internal/CollapsingTextHelper.java index df240962a84..c6b878d4456 100644 --- a/lib/java/com/google/android/material/internal/CollapsingTextHelper.java +++ b/lib/java/com/google/android/material/internal/CollapsingTextHelper.java @@ -767,8 +767,8 @@ public void draw(@NonNull Canvas canvas) { final int saveCount = canvas.save(); // Compute where to draw textLayout for this frame if (textToDraw != null && drawTitle) { - final float currentExpandedX = - currentDrawX + textLayout.getLineLeft(0) - expandedFirstLineDrawX * 2; + float firstLineX = maxLines > 1 ? textLayout.getLineStart(0) : textLayout.getLineLeft(0); + final float currentExpandedX = currentDrawX + firstLineX - expandedFirstLineDrawX * 2; textPaint.setTextSize(currentTextSize); float x = currentDrawX;