网格布局相关属性:
布局行数和列数
rowCount:行数
columnCount:列数
单元格操作
layout_row:子控件在布局的行数
layout_column:子控件在布局的列数
layout_rowSpan:跨行数
layout_columnSpan:跨列数
效果:
实现:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bk021"
android:gravity="center_horizontal"
tools:context=".MainActivity">
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:rowCount="7"
android:columnCount="5">
<TextView
android:layout_width="320dp"
android:layout_height="50dp"
android:layout_column="0"
android:layout_row="0"
android:layout_columnSpan="5"
android:gravity="right|center_vertical"
android:background="@drawable/custom_border"
android:paddingRight="10dp"
android:text="0123456789"
android:textColor="#0000ff"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp"
android:textSize="25sp"/>
<Button android:layout_width="65dp"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_column=