Skip to content

Commit ffef9f6

Browse files
dsn5ftymarian
authored andcommitted
[CollapsingToolbarLayout] Added support for multiline RTL when using fade title mode
PiperOrigin-RevId: 368237684 (cherry picked from commit f0ac362)
1 parent 63d01aa commit ffef9f6

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,10 +675,13 @@ private void calculateBaseOffsets() {
675675

676676
float measuredWidth = textToDraw != null
677677
? textPaint.measureText(textToDraw, 0, textToDraw.length()) : 0;
678-
width = textLayout != null && maxLines > 1 && !isRtl
678+
width = textLayout != null && maxLines > 1
679679
? textLayout.getWidth()
680680
: measuredWidth;
681-
expandedFirstLineDrawX = textLayout != null ? textLayout.getLineLeft(0) : 0;
681+
expandedFirstLineDrawX =
682+
textLayout != null
683+
? maxLines > 1 ? textLayout.getLineStart(0) : textLayout.getLineLeft(0)
684+
: 0;
682685

683686
final int expandedAbsGravity =
684687
GravityCompat.getAbsoluteGravity(
@@ -797,7 +800,7 @@ public void draw(@NonNull Canvas canvas) {
797800
}
798801

799802
private boolean shouldDrawMultiline() {
800-
return maxLines > 1 && !isRtl && !useTexture;
803+
return maxLines > 1 && (!isRtl || fadeModeEnabled) && !useTexture;
801804
}
802805

803806
private void drawMultinlineTransition(@NonNull Canvas canvas, float currentExpandedX, float y) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public StaticLayout build() throws StaticLayoutBuilderCompatException {
192192

193193
end = Math.min(textToDraw.length(), end);
194194
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
195-
if (isRtl) {
195+
if (isRtl && maxLines == 1) {
196196
alignment = Alignment.ALIGN_OPPOSITE;
197197
}
198198
// Marshmallow introduced StaticLayout.Builder which allows us not to use

0 commit comments

Comments
 (0)