2016-01-22 18 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"/> 
相关问题