2011-08-07 34 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> 

我想这整个布局出现在屏幕的底部。(不管用户有什么手机的分辨率)..

我希望两列在尺寸和平等底部位于水平中心。

+0

你的问题有点令人困惑,你可以把一些截图当作你目前和你想要什么? – PravinCG

+0

1)我想将两个底部对齐。 2)把整个事情放在屏幕的底部 –

+0

我怎样才能把两个按钮放在屏幕的底部? –

回答

3

要在屏幕的底部放置两个按钮,您可以这样做,伪代码添加相关属性。

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

谢谢,我改变了屏幕上的其他东西。所以这里的关键是对齐父母的底部..真...哦感谢 –