简体   繁体   中英

How to Justify the text and align properly in textview in android

I have one TextView in xml , but am giving the TextView values in java.while displaying its not proper alignment.Please can you give solution.

In Xml i give the values means it's displaying properly,but in java i am giving values its not showing in proper way.I want to justify the text

    <TextView 
    android:text="" android:id="@+id/result"
    android:layout_marginTop="13dp"
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="left|center|right" 
    android:gravity="left|center|right" 
    android:textStyle="bold" 
    android:textAlignment="center" 
    android:layout_marginRight="5dp" 
    android:layout_marginLeft="5dp"
    android:textSize="15dp" />

Android 0 supports justification of TextView. Please follow the below link

You can also use below library for Text Justfication.

Hope it helps

你只需要添加这个代码

 android:justificationMode="inter_word"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM