2013-05-13 78 views
0

代碼:上述Android網格佈局設置組件如何填充指定的行和列?

<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代碼。下面的結果:

enter image description here

如何各半設置兩個按鈕並填寫一條線嗎?

在此先感謝!

回答

1

你只是想要兩個底部按鈕來平均填充寬度?把它們放在一個帶有layout_width = fill_parent和水平方向的LinearLayout中。設置每一個具有相同的layout_weight,並且每個具有0dp的寬度。這將使他們的寬度相等。