android视图层的设计 javacode版本 有图哦

1. 於是先定義最大的view,並設定為目前佈局:
RelativeLayout r_layout = new RelativeLayout(this);
setContentView(r_layout)
2. 接著定義第二層的TableLayout,並加入到r_layout 裡:
TableLayout tableLayout = new TableLayout(this);
r_layout.addView(tableLayout, new RelativeLayout.LayoutParams(WC, WC));
3. 再定義第三層的TableRow,並加入到tableLayout 裡:
TableRow tableRow1 = new TableRow(this);
tableLayout.addView(tableRow1, new TableLayout.LayoutParams(WC, WC));
4. 最後,定義最小的view,並加入到tableRow裡:
ImageView iv = new ImageView(this);
tableRow1.addView(iv);
如此依序逐步定義,就能順利完成。

posted @ 2010-09-01 15:10  杨超路飞  阅读(250)  评论(0编辑  收藏  举报