我想將背景設置爲TextView
,我希望TextView
的大小爲背景和文本的大小。TextView背景拉伸
這裏是我的代碼:
<TextView
android:id="@+id/attackeNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="13dp"
android:paddingTop="8dp"
android:paddingLeft="35dp"
android:paddingRight="35dp"
android:singleLine="true"
android:ellipsize="end"
android:textSize="12sp"
android:text="thej hhekj hejk hjkesd ks dkl jsalkj dkl"
android:background="@drawable/attackee_name_background"/>
的結果是,該文本的「填充盒子」就好內配合,但背景被拉伸。
我是否必須爲TextView
分配一個固定的layout_width
?
只是分配給背景屬性配合中心;) – JackTurky 2012-02-02 09:49:02
您可以使用bacground圖像爲[9補丁(http://developer.android.com/guide/developing/tools/draw9patch.html) – 2012-02-02 09:49:45
如何分配我財產的背景? – piojo 2012-02-02 09:50:05