从表格布局中可以了解到,无法实现跨行。网格布局不仅能实现跨行、还能实现跨列,并且,该种布局能自动进行子元素的定位,在使用上,更加灵活。
知识点1:设置最大行数和最大列数
最大行数设置(假设为2):android:rowCount="2"
最大列数设置(假设为4):android:columnCount="4"
案例1:设置最大行数和最大列数(但是无法限制组件个数)
<?xml version="1.0" encoding="utf-8"?>
<GridLayout 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:rowCount="2"
android:columnCou