3
我想动态添加行到tablelayout。这是我的代码。动态创建tablelayout android
TableRow tableRow = null;
TextView textView = null;
ImageView imageView = null;
TableLayout tableLayout = (TableLayout)findViewById(R.id.tableLayout);
RelativeLayout relativeLayout = null;
for (String string: listOfStrings) {
tableRow = new TableRow(this);
relativeLayout = (RelativeLayout) View.inflate(this,
R.layout.row, null);
textView = (TextView) relativeLayout.getChildAt(0);
textView.setText(string);
imageView= (ImageView) relativeLayout.getChildAt(1);
imageView.setBackgroundColor(R.color.blue);
tableRow.addView(relativeLayout);
tableLayout.addView(tableRow);
}
我已经创建了宽度FILL_PARENT一排布局,TextView的在最左侧和最右侧的ImageView的。但是,当我运行这个程序时,行宽出现wrap_content而不是fill_parent与图像重叠文本。请帮忙。谢谢