2011-06-26 5 views
0

J'ai écrit ce code XML;Problème Android TableLayout et Gallery

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="20" 
> 
<TableRow 
    android:layout_height="fill_parent" 
    android:layout_weight="10" 
    android:layout_width="fill_parent">`enter code here`</TableRow> 
<TableRow 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:layout_weight="9"> 
    <Gallery 
    android:layout_height="fill_parent" 
    android:id="@+id/gallery" 
    android:layout_width="fill_parent" 
    android:layout_weight="1"> 
    </Gallery> 
</TableRow> 
<TableRow 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" 
    > 
    <Button 
     android:id="@+id/Button1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:layout_weight="1" 
     > 
    </Button> 
    <Button 
     android:id="@+id/Button2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:layout_weight="1"> 
    </Button> 
    <Button 
     android:id="@+id/Button3" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:layout_weight="1"> 
    </Button> 
    <Button 
     android:id="@+id/Button4" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:layout_weight="1"> 
    </Button> 
</TableRow> 

Ce code est montré comme je veux mais quand je lance la taille des boutons de code changent avec des images de taille en gallery.How je peux écrire le code XML indépendant de l'autre (galerie et boutons) . Merci pour l'aide

Répondre

1

Je vous recommande d'utiliser 2 LinearLayouts, un LinearLayout vertical pour contenir la Gallery et un LinearLayout horizontal, qui à son tour contient les différents boutons.

code:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 
    <Gallery 
     android:layout_height="fill_parent" 
     android:id="@+id/gallery" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
    </Gallery> 
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"> 
     <Button 
      android:id="@+id/Button1" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:layout_weight="1"> 
     </Button> 
     <Button 
      android:id="@+id/Button2" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:layout_weight="1"> 
     </Button> 
     <Button 
      android:id="@+id/Button3" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:layout_weight="1"> 
     </Button> 
     <Button 
      android:id="@+id/Button4" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center" 
      android:layout_weight="1"> 
     </Button> 
    </LinearLayout> 
</LinearLayout> 
+0

Je tryed votre recommandation, mais il semble same.Could vous envoyez le code? – David

+0

Merci beaucoup – David

+0

De rien. – sparkymat