0

代码:

<GridLayout 
  xmlns:tools="http://schemas.android.com/tools"
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"  
  android:layout_height="match_parent"   
  android:rowCount="6"  
  android:columnCount="4" >  

<!-- define textbox,Across the four columns -->

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_columnSpan="4"
    android:textSize="50sp"
    android:layout_marginLeft="4px"
    android:layout_marginRight="4px"
    android:padding="5px"
    android:layout_gravity="right"
    android:background="#eee"
    android:textColor="#000"
    android:text="test"
    />
<!-- define two buttons,Delete and reset -->

<Button
    android:id="@+id/bn1"
    android:layout_columnSpan="2" 
    android:layout_rowSpan="1"
    android:layout_gravity="fill"
    android:text="clear"
     /> 

<Button
    android:id="@+id/bn2"
    android:layout_columnSpan="2" 
    android:layout_rowSpan="1"
    android:layout_gravity="fill"     
    android:text="selete"
    />

以上是mail.xml 代码。结果如下:

在此处输入图像描述

如何设置两个按钮一半和一半并填充一条线?

提前致谢!

4

1 回答 1

1

You just want the two bottom buttons to fill the width equally? Put them in a LinearLayout with layout_width=fill_parent and horizontal orientation. Set each one to have the same layout_weight, and each one to have a width of 0dp. That will make them equal width.

于 2013-05-13T05:18:51.330 回答