③表格布局(TableLayout)
表格布局就是让控件以表格的形式来排列组件的,只要将组件或信息放在单元格中,控件就可以整齐的排列。在TableLayout中,行数由TableRow对象控制的,即布局中有多少TableRow对象,就有多少行。
注:
①如果我们直接往TableLayout中添加组件的话,那么这个组件将占满一行!
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="a">
</Button>
</TableLayout>
②如果我们想一行上有多个组件的话,就要添加一个TableRow的容器,把组件都丢到里面
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="match_parent"
android