android视图层的设计 javacode版本 有图哦
16lz
2021-01-24
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);
如此依序逐步定義,就能順利完成。
更多相关文章
- Android(安卓)中编译版本,最小版本, 目标版本都有什么区别?
- Android(安卓)屏幕适配--最小宽度限定符适配
- WPF UI组件学习(一) - Window的外观实现及常用属性
- Android(安卓)返回桌面的操作
- Static interface methods are only supported starting with An
- 下载AOSP android源码(最小最快下载方式,跳过编译直接导入Android(
- Android不完全退出主Activity的方法
- Android获取CPU信息(主频,使用率)
- 最短路径之狄克斯特拉(Dijkstra)算法