Search code examples
androidtextviewandroid-appcompatautosize

Android Auto text sizing not working


I am trying to make my application responsive by putting the auto resize text option but it seems that its not working. I am using the android auto size tag :

 <TextView
        android:id="@+id/textView11"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="60px"
        android:paddingTop="160px"
        android:text="@string/greetings1"
        android:textColor="@color/black"
        app:autoSizeTextType="uniform"
        app:autoSizeMinTextSize="5sp"
        app:autoSizeMaxTextSize="100sp"
        app:autoSizeStepGranularity="2sp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:ignore="MissingPrefix" />

When I run it on my phone it does not resize at all. please help


Solution

  • From Autosizing TextViews

    If you set autosizing in an XML file, it is not recommended to use the value "wrap_content" for the layout_width or layout_height attributes of a TextView. It may produce unexpected results.

    You should bound Height

    android:layout_width="match_parent"
    android:layout_height="50dp"