2011-08-08 1 views
0

Je voudrais avoir une disposition qui ressemble à ceci (en mode paysage): - sur le dessus 4 bouton à espacement égal - au milieu: un bloc EditText et à côté de lui sur sa droite un ImageButton - en bas une vue de texte.Disposition Android: combiner LinearLayout et TableLaout

Voici le fichier xml que je l'habitude de mettre en œuvre cette disposition:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_height="fill_parent" 
android:layout_width="fill_parent" 
android:padding="20dip" 
> 


<TableLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:stretchColumns="*"> 

<TableRow> 

<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:drawableTop="@drawable/b1" 
android:drawablePadding="5sp" 
android:text="B1"></Button> 

<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:drawableTop="@drawable/b2" 
android:drawablePadding="5sp" 
android:text="B2"></Button> 

<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:drawableTop="@drawable/b3" 
android:drawablePadding="7sp" 
android:text="B3"></Button> 

<Button 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:drawableTop="@drawable/b4" 
android:drawablePadding="7sp" 
android:text="B4"></Button> 

</TableRow> 
</TableLayout> 

<TableLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:stretchColumns="*"> 

<TableRow> 

<EditText 
android:id="@+id/entry" 
android:layout_width="200dp" 
android:layout_height="50dp" 
android:layout_below="@id/e1" 
android:layout_marginLeft="20dp" 
android:layout_marginTop="10dp" 
/> 
<ImageButton 
android:id="@+id/search2" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:src="@drawable/i1" 
android:layout_marginTop="10dp" 
/> 

</TableRow> 

<TextView 
android:id="@+id/t2" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="T2"/> 

</TableLayout> 

</LinearLayout> 

Cependant, ce que je dis est de 4 boutons en haut de la façon dont je veux, et le reste (deuxième ligne et troisième rangée) est pas sur la page (ne peut pas être vu). Je ne sais pas où ils sont allés. J'apprécie toute aide pour cela. Merci,

TJ

Répondre

2

Ajouter

android:orientation="vertical" 

dans LinearLayout mère.

+0

Merci, c'était le problème, j'apprécie votre aide. – TJ1

+1

... car l'orientation par défaut d'un LinearLayout est horizontale. –