2011-11-05 4 views
2

http://img804.imageshack.us/img804/9858/howtowrapmiddletext.pngComment envelopper texte android listview

Fondamentalement j'ai un ListView qui est divisé en trois sections. Sur la gauche est une image, le droit est un bouton, et le milieu est le texte que je veux emballé. Voir ma photo pour ce que je parle

Voici ma mise en page 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> 

Répondre

4

Ok, voici quelques choses que vous pouvez essayer:

1) Avez-vous android:orientation="horizontal" dans votre linearlayout?

2) pour votre EditText, définissez android:inputType="textMultiLine"

si cela ne fonctionne pas, 3) pour votre EditText, définissez android:layout_width="0dip" et android:layout_weight="1"

+1

Il suffit de faire # 1. # 2 ne devrait pas avoir d'importance. Ajoutez également layout_weight = "1" à TextView, au cas où le texte est inférieur à la largeur totale. Dans le même ordre d'idées, je suggère de faire de l'image de gauche une dimension exacte, pour ne pas avoir d'alignement bizarre. –

+0

Merci les gars! Je l'ai fait en réglant LinearLayout 'android: orientation =" horizontal' "et en ajoutant" layout_weight = "1" 'dans le TextView, c'était la combinaison de touches. – Darcy