Android TextView

时间:2011-05-04 10:39:22

标签: android textview tablelayout

我创建了tablelayout并在tablelayout m动态添加行。同时动态地在行中添加四个TextViewTextView大小各不相同。我的问题是如何相应地设置TextView的高度。即如果一个TextView的大小相应增加,则调整该特定行高。请帮帮我。

1 个答案:

答案 0 :(得分:0)

以下几个步骤可能对您有帮助。

1)将表格行宽设置为fill_parent&高度为wrap_content。 2)按照你想要在ui上显示的顺序添加这四个textview。

e.g

tablerow.addview(textView1,LayoutParams.wrap_content,LayoutParams.wrap_content);
  tablerow.addview(textView2,LayoutParams.wrap_content,LayoutParams.wrap_content);
  tablerow.addview(textView3,LayoutParams.wrap_content,LayoutParams.wrap_content);
  tablerow.addview(textView4,LayoutParams.wrap_content,LayoutParams.wrap_content);

&安培;最后

table.addView(tablerow,LayoutParams.FILL_PARENT,LayoutParams.wrap_content));