Android TextView ellipsize wrong with RTL text

334 Views Asked by At

I have an AppCompatTextView with some RTL text (Persian text, actually), and I set its maxLines to 1 and ellipsize value to end. But it doesn't work properly.

This is my AppComaptTextView:

<androidx.appcompat.widget.AppCompatTextView
    android:id="@+id/aditem_category"
    android:layout_width="0dp"
    android:layout_height="18dp"
    android:ellipsize="end"
    android:gravity="right|center_vertical"
    android:layoutDirection="ltr"
    android:lines="1"
    android:maxLines="1"
    android:text="تست متن طولانی در نرم‌افزار اندروید که متن عمداً طولانی شده است"
    android:textAlignment="gravity"
    android:textDirection="rtl"
    app:autoSizeMaxTextSize="14sp"
    app:autoSizeMinTextSize="12sp"
    app:autoSizeStepGranularity="1px"
    app:autoSizeTextType="uniform"
    app:layout_constraintBottom_toBottomOf="@id/image"
    app:layout_constraintEnd_toStartOf="@id/iconCategory"
    app:layout_constraintStart_toStartOf="parent"
    ... Other properties ... />

Please read the properties well. I typed those properties which were important to know. But what I get is:

Screenshot

The problems are:

  1. The ellipsis is at right (start of an RTL text)
  2. It has too much spacing, but there is room for some other words
  3. The whole text is at left, but I set its gravity to right|center_vertical

Note: when the text isn't long, none of these problems exist.

What should I do?

0

There are 0 best solutions below