【例1-3】表格布局应用示例
将图像文件mmx.jpg复制到drawable目录下, 然后设计一个3行4列的 TableLayout 表格布局

布局文件activity_main3.xml的源代码
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/mmx" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/mmx" />
</TableRow>
<TableRow>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/mmx"
android:layout_column="1"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/mmx"
android:layout_column="2"/>
</TableRow>
<TableRow>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/mmx"
android:layout_column="3"/>
</TableRow>
</TableLayout>
控制文件MainActivity.java源代码
package com.example.chap01;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
//与教材的android.support.v7.app.AppCompatActivity不同
public class MainActivity extends AppCompatActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
}
}

