android 纯代码TableLayout布局

谁可以帮忙写个纯代码的表格布局示例:

样式 :

     top

left center right

   bottom

main.xml
[code="java"]<?xml version="1.0" encoding="utf-8"?>
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello" />
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mytable"
    android:layout_width="260px"
    android:layout_height="260px"
    android:stretchColumns="*"
    android:layout_span="3"
    ></TableLayout>

[/code]
主要是加了这部分

java部分
[code="java"]
package com.androidtest.drawtablelayout;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TableLayout;
import android.widget.TableLayout.LayoutParams;
import android.widget.TableRow;
import android.widget.TextView;

public class DrawTableLayoutByJavaActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TableLayout mytable = (TableLayout) findViewById(R.id.mytable);
int numberOfRow =3;
int numberOfColumn =3;
int cellDimension =24;
int cellPadding =2;
for (int row = 0;row<numberOfRow; row ++){
TableRow tableRow = new TableRow(this);
tableRow.setLayoutParams(new LayoutParams((cellDimension+2*cellPadding)*numberOfColumn,cellDimension +2*cellPadding));
for (int column =0;column<numberOfColumn; column++){
TextView textView = new TextView(this);
textView.setText("");
if(row == 0 && column == 1) textView.setText("top");
if(row == 1 && column == 0) textView.setText("left");
if(row == 1 && column == 1) textView.setText("center");
if(row == 1 && column == 2) textView.setText("right");
if(row == 2 && column == 1) textView.setText("button");
tableRow.addView(textView);
}
mytable.addView(tableRow,new LayoutParams((cellDimension+2*cellPadding)*numberOfColumn,cellDimension +2*cellPadding));
}
}
}
[/code]

<?xml version="1.0" encoding="utf-8"?>
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:stretchColumns="0,1,2" android:shrinkColumns="1,2">

<TableRow>
    <TextView 
        android:layout_column="1" 
        android:text="top"
        android:gravity="center" />
</TableRow>

<TableRow>
    <TextView android:text="left" android:gravity="left" />
    <TextView android:text="center" android:gravity="center" />
    <TextView android:text="right" android:gravity="right" />
</TableRow>

<TableRow>
    <TextView android:layout_column="1" android:text="bottom"
        android:gravity="center" />
</TableRow>

三行的距离没有拉开,这个比较简单。