Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android网格布局集组件如何填充指定的行和列?_Android_Layout - Fatal编程技术网

Android网格布局集组件如何填充指定的行和列?

Android网格布局集组件如何填充指定的行和列?,android,layout,Android,Layout,代码: <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:col

代码:

<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代码。结果如下:

如何将两个按钮对半设置并填充一行


提前谢谢

您只想让底部的两个按钮均匀地填充宽度?将它们放置在线性布局中,布局\宽度=填充\父对象和水平方向。将每一个设置为具有相同的布局重量,并将每一个设置为具有0dp的宽度。这将使它们的宽度相等