我有一個textview,我已經設置了它的圖像背景。該圖像沒有調整文本的大小。TextView背景圖像不能調整文本大小
例如: - 如果我的文本是「A」,背景仍然是相同的,不能調整大小以適應文本。這裏是TextView中的XML: -
<TextView
android:id="@+id/navmenusection_right_label_action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:background="@drawable/textview_round_background"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:text="A"
android:textColor="#fff"
android:textSize="13sp"
android:textStyle="bold"/>
爲什麼不使用9Patch圖形?這意味着可調整大小視圖的背景,請記住,9個補丁不會越來越小,因此只能繪製最小大小http://developer.android.com/tools/help/draw9patch.html –
您正在使用9Patch?如果是的話,你還設置了圖像的填充線嗎?因爲這可能是你的問題.. – Cata
背景將會伸展但不縮水。使用最小尺寸的9patch。或者如果你不想去9patch去尋找更小版本的背景。 – dmSherazi