【例1-3】表格布局应用示例
将文件mmx.jpg复制到drawable目录, 然后设计一个表格布局。

教学视频
1 布局文件activity_main3.xml的源代码
<?xml version="1.0" encoding="utf-8"?>
<!--【例1-3】表格布局应用示例 -->
<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>
2 控制文件MainActivity.java源代码
package com.example.chap01;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3); //【例1-3】
}
}

