How to make TextView in Android cover and customize text beautifully?

When the text is small, I get the following:

enter image description here

But when the text is large, I get the following:

enter image description here

Is it possible for the text to adjust itself, perhaps better using spaces or reducing the small size automatically?

This is my TextView xml:

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/seaGreen"
            android:gravity="center_vertical"
            android:padding="10dp"
            android:textColor="@color/white"
            android:textSize="35sp" />
+4
source share
2 answers

To do this, you need to use an external library for this, otherwise you can set gravity as the center

Library:

https://github.com/grantland/android-autofittextview

To align text

https://github.com/bluejamesbond/TextJustify-Android

https://github.com/programingjd/justified

OR

you can check this answer

+1
this work for me:    
 <TextView
        android:id="@+id/your_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:textAlignment="center"
        android:gravity="center"
        android:padding="5dp"
        android:text=""
        android:textSize="14sp"/>
+1

Source: https://habr.com/ru/post/1625453/


All Articles