我有一个TableLayout
单一的 Android 活动 UI。它有两列。现在我需要添加一个新行,并EditText
在该新行的第二列中放置一个框。而且,我希望它EditText
填满整个单元格。我有一些这样的代码:
TableRow tr = new TableRow(context);
EditText et = new EditText(context);
et.SetMaxLines(4);
etText.setLayoutParams(new TableRow.LayoutParams(1)); //set it to the second coloumn
tr.addView(et);
tl.addView(tr); //tl is the tableLayout
它把EditText
第二列很好,但是EditText
太小了。我试着用
etText.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
但这似乎禁用了该TableRow.LayoutParams
设置。我猜每个控件只能有一个LayoutParams
设置。
那么,如何将 EditText 设为 4 行文本编辑器并确保它位于该行的第二列?
谢谢。