2
http://img804.imageshack.us/img804/9858/howtowrapmiddletext.png如何包裝文本android listview
基本上我有一個列表視圖分爲三部分。左邊是圖像,右邊是按鈕,中間是我想要包裝的文字。見我的照片什麼我談論
這裏是我的XML佈局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/ic_tab_drink_selected"
android:id="@+id/img1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="16sp"
android:id="@+id/text1"/>
<Button
android:id="@+id/btn1"
android:layout_width="60dp"
android:layout_height="60dp"
/>
</LinearLayout>
只要做到#1。 #2應該不重要。另外,如果文本小於全部寬度,則向TextView添加layout_weight =「1」。沿着同樣的路線,我會建議讓左圖像成爲精確的尺寸,所以你不會奇怪的對齊。 –
謝謝你們!我通過在TextView中設置LinearLayout android:orientation =「horizontal」並添加了'layout_weight =「1」'來實現它,這是關鍵組合。 – Darcy