1

I am using autosize textview with appcompat and I get an issue I don't know if you have ever faced off.

If I have a Textview with maximum and minimum text sizes, fixed width and height, gravity to center, and, a text so long that it should be ellipsized, I don't know why but some characters are cut at the beginning.

Let me show you the code:

Having this layout

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/title"
        android:layout_width="0dp"
        android:layout_height="24dp"
        android:layout_marginStart="40dp"
        android:layout_marginEnd="40dp"
        android:gravity="center"
        android:letterSpacing="0.2"
        android:maxLines="1"
        app:autoSizeTextType="uniform"
        app:autoSizeMaxTextSize="16sp"
        app:autoSizeMinTextSize="14sp"
        app:fontFamily="@font/apercu_medium"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
    />

    ...

</androidx.constraintlayout.widget.ConstraintLayout>

For a long text such as "12345 67 89 012345678 90123456 7890123 45 67890123", text is unexpectedly cut at the beginning as you can see below.

bug result

However, if I set Textview gravity to start and center_vertically, it is correctly displayed.

expected result

By the way, I am using androidx.appcompat:appcompat with version 1.1.0-rc01.

Thanks in advance!

José Carlos
  • 604
  • 5
  • 16

0 Answers0