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

来源:互联网 发布:分布式一致性算法 编辑:程序博客网 时间:2024/05/30 04:30

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);
如此依序逐步定義,就能順利完成。

原创粉丝点击