思维导图:
GridLayout布局使用虚细线将布局划分为行、列和单元格,也支持一个控件在行、列上都有交错排列。
二、常用属性
1、针对布局的属性
(1)rowCount:行数
(2)columnCount:列数
2、针对子控件的属性
(1)layout_row:子控件在布局的行数
(2)layout_column:子控件在布局的列数
(3)layout_rowSpan:跨行数
(4)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="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/background"
android:orientation="vertical"
android:padding="15dp"
tools:context="net.hw.demo0404.MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/custom_border"
android:gravity="right|center_vertical"
android:paddingRight="10dp"
android:text="0123456789"
android:textColor="#0000ff"
android:textSize="25sp" />
<GridLayout