答案 0 :(得分:1)
如果您使用的是v7支持库中的GridLayout。
compile 'com.android.support:gridlayout-v7:22.2.1'
参考此代码,
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_column="4"
android:layout_row="5"
android:layout_height="match_parent">
<Button android:layout_width="0dp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_row="0"
android:layout_height="wrap_content"/>
<Button android:layout_width="0dp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_row="0"
android:layout_height="wrap_content"/>
<Button android:layout_width="0dp"
app:layout_column="2"
app:layout_columnWeight="1"
app:layout_row="0"
android:layout_height="wrap_content"/>
<Button android:layout_width="0dp"
app:layout_column="3"
app:layout_row="0"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
<!-- 2nd -->
<Button android:layout_width="0dp"
app:layout_column="0"
app:layout_columnSpan="4"
app:layout_row="1"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
<!-- 2nd -->
<Button android:layout_width="0dp"
app:layout_column="0"
app:layout_row="2"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
<Button android:layout_width="0dp"
app:layout_column="1"
app:layout_row="2"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
<Button android:layout_width="0dp"
app:layout_column="2"
app:layout_row="2"
app:layout_columnSpan="2"
app:layout_columnWeight="2"
android:layout_height="wrap_content"/>
<!-- 3rd -->
<Button android:layout_width="0dp"
app:layout_column="0"
app:layout_row="3"
app:layout_columnSpan="2"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
<Button android:layout_width="0dp"
app:layout_column="2"
app:layout_row="3"
app:layout_columnSpan="2"
app:layout_rowSpan="3"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
<!-- 3rd -->
<Button android:layout_width="0dp"
app:layout_column="0"
app:layout_row="4"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
<Button android:layout_width="0dp"
app:layout_column="1"
app:layout_row="4"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
<!-- 3rd -->
<Button android:layout_width="0dp"
app:layout_column="0"
app:layout_row="5"
app:layout_columnSpan="2"
app:layout_columnWeight="1"
android:layout_height="wrap_content"/>
</android.support.v7.widget.GridLayout>