TableLayout 实现动态新增一行,与之前行宽度一致
来源:互联网 发布:qq游戏大厅mac版下载 编辑:程序博客网 时间:2024/05/22 15:50
转自:http://63230860.blog.163.com/blog/static/65880996201321133014272/
其中说几个属性,在tablelayout 中,android:stretchColumns="*" 这一个是设置自动拉伸列的,把各个列拉伸以满足屏幕
在tableRow中的view里面,对每一个view的android:layout_width="1dip",这样设置可以使各个列的宽度保持一致
代码:为了简洁一点,就少贴出来3列
xml
<TableLayout
android:id="@+id/work_censustable_id"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:stretchColumns="*"
>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="1dip"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/work_census_comm"
android:background="@drawable/table_view"
android:textSize="11dp" />
<TextView
android:layout_width="1dip"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/work_inspect"
android:background="@drawable/table_view"
android:textSize="11dp" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="1dip"
android:background="@drawable/table_view"
android:gravity="center"
android:text="合计"
android:textSize="11dp" />
<TextView
android:layout_width="1dip"
android:background="@drawable/table_view"
android:gravity="center"
android:text="1"
android:textSize="11dp" />
</TableRow>
</TableLayout>
Activity:
TableLayout layout = (TableLayout) findViewById(R.id.work_censustable_id);
TableRow row = new TableRow(this);
TextView textView1 = new TextView(this);
textView1.setText("社区"+k);
textView1.setTextSize(11);
textView1.setBackgroundResource(R.drawable.table_view);
textView1.setGravity(Gravity.CENTER);
row.addView(textView1);
TextView textView2 = new TextView(this);
textView2.setText("1");
textView2.setTextSize(11);
textView2.setBackgroundResource(R.drawable.table_view);
textView2.setGravity(Gravity.CENTER);
row.addView(textView2);
TextView textView3 = new TextView(this);
textView3.setText("6");
textView3.setTextSize(11);
textView3.setBackgroundResource(R.drawable.table_view);
textView3.setGravity(Gravity.CENTER);
row.addView(textView3);
layout.addView(row,new TableLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
- TableLayout 实现动态新增一行,与之前行宽度一致
- TableLayout 实现动态添加内容
- android 使用TableLayout 实现布局自动拉伸宽度
- js动态生成table的一行 并且是复制的当前行 列都一起生成了
- TableLayout 动态表格
- 动态fragment+viewpage+tablelayout
- easyui新增一行统计数据
- 用触发器实现动态新增列
- Android 使用 TableLayout 布局拉伸宽度
- Android 使用 TableLayout 布局拉伸宽度
- Android控件之TableLayout布局拉伸宽度
- sublime复制当前行到下一行
- js 动态添加标签(新增一行,其实很简单,就是几个函数的应用)
- Android TableLayout 实现边框
- Android TableLayout 实现边框
- Android TableLayout实现边框
- Android TableLayout实现边框
- TableLayout实现登录界面
- ExecutorSevice & FutureTask
- 这一年的八月三十一号
- 过河
- 【Python】爬图片,Py2exe打包成EXE,并用inno setup生成安装文件
- 最近S2SH框架整合和简单测试 Struts2-2.3.14+Spring-4.0.6+Hibernate-4.3.6
- TableLayout 实现动态新增一行,与之前行宽度一致
- vector的clear操作的内部过程
- 字符转换
- BZOJ 1708: [Usaco2007 Oct]Money奶牛的硬币
- [UVA]11524 - InCircle
- URAL 1019. Line Painting 线段树 区间合并 离散化
- Codeforces 319B. Psychos in a Line【栈】
- linux中命令的返回值
- hadoop2.2.0对应HBase安装说明