Text does not adapt to TextView

76 views Asked by At

I need to insert a large text in a TextView, but when pasting the text it does not adapt to the size of the TextView, because it has exceeded the width of the TextView and the text is giant, how to fix this?

Note: I need to correct it using the Android Studio visual interface.

My PrintScreen

1

There are 1 answers

1
iknow On BEST ANSWER

To set optimal size of the text in TextView You can use autoSizeTextType property. To do it Your TextView must have fixed sizes or match_parent. Then You can use autoSizeTextType It looks something like this:

<TextView
    android:layout_width="match_parent"
    android:layout_height="150dp"
    android:text="@string/lorem_ipsum"
    app:autoSizeTextType="uniform"
    app:autoSizeMinTextSize="12sp"
    app:autoSizeMaxTextSize="100sp"
    />

Results:

TextView height : 150dp

enter image description here


TextView height : 300dp

enter image description here

Here is a short video on YouTube with great explanation