AppCompatTextView autoSizeTextType is weird with hint

102 Views Asked by At

I've been experiencing very weird behavior of AppCompatTextView's autoSizeTextType.
I found where the problem is but i don't get it at all. There is a AppCompatTextView in a ConstraintLayout. it's only child of the XML.

activity_main.xml

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.appcompat.widget.AppCompatTextView
        android:id="@+id/testView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="Hello World!"
        android:padding="5dp"
        app:autoSizeMaxTextSize="10dp"
        app:autoSizeMinTextSize="7dp"
        app:autoSizeTextType="uniform"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

and the result is like this below.
enter image description here
enter image description here
Can you see it? i didn't make the hint horizontally to show like that. But if i change the 7dp with 10dp, the problem will be gone.

enter image description here

But i can't do that because the autoSizeMaxTextSize and autoSizeMinTextSize should not be the same.
What's happening here now? is it a bug?

Edit)

The only workdaround that i just found is to set `android:ellipisze="end"`. the middle, start, marquee also work well.
1

There are 1 best solutions below

1
On

Replace app with android

app will assign values from values.xml

android will assign values from attrs.xml

  <!-- The minimum text size constraint to be used when auto-sizing text. -->
        <attr name="autoSizeMinTextSize" format="dimension" />
        <!-- The maximum text size constraint to be used when auto-sizing text. -->
        <attr name="autoSizeMaxTextSize" format="dimension" />
android:autoSizeMaxTextSize="10dp"
android:autoSizeMinTextSize="7dp"