2011-08-07 15 views
0

2つのボタンを画面の中央に表示するようにしたいのですが、画面の下部に表示します。2つのボタンをレイアウトする方法

これまでの説明はここにあります。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 

    <TableLayout android:layout_width="match_parent" 
    android:id="@+id/tableLayout2" 
    android:layout_gravity="center" 
    android:layout_height="fill_parent" 
    android:stretchColumns="@string/app_name"> 

     <TableRow android:id="@+id/tableRow1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

      <Button android:text="History" 
      android:layout_height="wrap_content" 
      android:layout_gravity="center_horizontal" 
      android:layout_width="fill_parent" 
      android:id="@+id/button1" 
      ></Button> 
      <Button android:text="RecordSpending" 
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:id="@+id/button2" 
      android:gravity="center_vertical"></Button> 
     </TableRow> 

    </TableLayout> 
</LinearLayout> 

私は(関係なく、ユーザーが持っているもの電話解像度)..この全体のレイアウトは、画面の下部に表示したいん...

私は2つの列のサイズが等しくなるようにしたいと中央に水平に位置する底部。

+0

あなたの質問はちょっと混乱しています。あなたが現在持っているものとあなたが望むものについてのスクリーンショットを貼ることができますか? – PravinCG

+0

1)私は2つのボトムを中心にしたい。 2)全体を画面の一番下に置く –

+0

画面下部に2つのボタンを配置するにはどうすればいいですか? –

答えて

3

スクリーンの下部に2つのボタンを置くには、これを行うことができます。擬似コードは、関連する属性を追加します。

<!-- This is the parent layout -->  
<RelativeLayout 
android:layout_height="fill_parent" 
android:layout_width="fill_parent" > 

    <!-- Layout for your buttons at bottom --> 
    <LinearLayout 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_alignParentBottom="true"> 
     <!-- weight = 1 would mean both buttons are of equal width --> 
     <Button 
     android:layout_height="wrap_parent" 
     android:layout_width="0dp" 
     android:layout_weight="1.0" />   
     <Button 
     android:layout_height="wrap_parent" 
     android:layout_width="0dp" 
     android:layout_weight="1.0" /> 

    </LinearLayout> 
</RelativeLayout> 
+0

ありがとう、私はsmething elseに表示を変更しました。だからここの鍵は、親の底にぴったりです。 –

関連する問題