表格布局案例
实现如下案例
上代码:
<TableLayout 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:stretchColumns="*" >
<TextView
android:layout_width="match_parent"
android:gravity="center"
android:background="#FFA500"
android:layout_height="wrap_content"
android:text="学生信息表"
android:textSize="25dp" />
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#7FFFAA">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="学号"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="姓名"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="性别"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="班级"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="张三"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="男"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="1班"/>
</TableRow>
</TableLayout>