MarqueeTextViewCompat: rtl scrolling fix

This commit is contained in:
Yuriy Liskov
2026-02-25 00:10:56 +02:00
parent 132a63882d
commit b3da5fdb22
2 changed files with 12 additions and 10 deletions

View File

@@ -300,6 +300,14 @@ public class MarqueeTextViewCompat extends TextView {
}
}
@Override
public void setLayoutDirection(int layoutDirection) {
super.setLayoutDirection(layoutDirection);
if (mTextView != null) {
mTextView.setLayoutDirection(layoutDirection);
}
}
@Override
public void setTextDirection(int textDirection) {
super.setTextDirection(textDirection);

View File

@@ -103,19 +103,12 @@ public class ViewUtil {
}
public static void applyMarqueeRtlParams(TextView textView, boolean scroll) {
//if (VERSION.SDK_INT <= 17) {
// return;
//}
//if (!BidiFormatter.getInstance().isRtlContext()) {
// return;
//}
if (!Helpers.isTextRTL(textView.getText())) {
// TextView may be reused from rtl context. Do reset.
// NOTE: don't enable commented options because Setting item's text won't be centered.
//textView.setTextAlignment(View.TEXT_ALIGNMENT_GRAVITY);
textView.setTextDirection(TextView.TEXT_DIRECTION_FIRST_STRONG);
textView.setTextDirection(View.TEXT_DIRECTION_LTR);
textView.setLayoutDirection(View.LAYOUT_DIRECTION_LTR);
//textView.setGravity(Gravity.TOP | Gravity.START);
return;
}
@@ -124,7 +117,8 @@ public class ViewUtil {
// Fix: right scrolling on rtl languages
// Fix: text disappear on rtl languages
textView.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_END);
textView.setTextDirection(TextView.TEXT_DIRECTION_RTL);
textView.setTextDirection(View.TEXT_DIRECTION_RTL);
textView.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
textView.setGravity(Gravity.START);
} else {
// Fix: text disappear on rtl languages