2011-06-26 7 views
0

私はこのXMLコードを書いています。Android XML tableLayoutとギャラリーの問題

<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> 

このコードは、私はお互い(ギャラリーやボタン)から独立したXMLコードを記述することができますgallery.Howの画像サイズで変更されたコードのボタンのサイズを実行したとき、私はしかし、したいように示されています。 ありがとうございました

答えて

1

2つのLinearLayouts、ギャラリーを保持する垂直のLinearLayout、さまざまなボタンを含む水平のLinearLayoutを使用することをお勧めします。

コード:

<?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

私はあなたをお勧めしようと試みたが、それはあなたがコードを送信same.Couldに見えますか? – David

+0

ありがとうございました – David

+0

よろしくお願いします。 – sparkymat