2011-11-05 27 views
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> 

回答

4

好了,這裏有一些事情你可以嘗試:

1)你在有android:orientation="horizontal"你的LinearLayout?

2)爲您的EditText,設置android:inputType="textMultiLine"

如果不工作, 3)爲您的EditText,設置android:layout_width="0dip"android:layout_weight="1"

+1

只要做到#1。 #2應該不重要。另外,如果文本小於全部寬度,則向TextView添加layout_weight =「1」。沿着同樣的路線,我會建議讓左圖像成爲精確的尺寸,所以你不會奇怪的對齊。 –

+0

謝謝你們!我通過在TextView中設置LinearLayout android:orientation =「horizo​​ntal」並添加了'layout_weight =「1」'來實現它,這是關鍵組合。 – Darcy