2016-01-22 16 views
4

當文字是小然後我得到這樣的:如何使Android中的TextView打包並精美地調整文本?

enter image description here

但是,當文字是大我得到這個:

enter image description here

難道文本通過,也許更好的利用空間調整本身或自動減小尺寸?

這是我的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" /> 
+1

沒了爲你需要使用外部庫對於這一點,否則你可以設置重心爲中心 – Madhur

+0

@Madhur哪個庫?任何想法 –

+0

你有沒有試過這個? http://stackoverflow.com/a/5535672/1549865 – barikatul

回答

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"/> 
相關問題