0
如何设置layout_span,在android系统如何设置layout_span,在代码中动态layout_margin在android系统
如何设置layout_span,在android系统如何设置layout_span,在代码中动态layout_margin在android系统
在代码中动态layout_margin您可以设置layout_margin与给TableRow.addView()
一个TableRow.LayoutParams
实例:
TableLayout newTable = new TableLayout(DisplayContext);
int rowIndex = 0;
// First Row (3 buttons)
TableRow newRow1 = new TableRow(DisplayContext);
newRow1.addView(new Button(DisplayContext), 0);
newRow1.addView(new Button(DisplayContext), 1);
newRow1.addView(new Button(DisplayContext), 2);
newTable.addView(newRow1, rowIndex++);
// Second Row (2 buttons, last one spans 2 columns)
TableRow newRow2 = new TableRow(DisplayContext);
newRow2.addView(new Button(DisplayContext), 0);
Button newButton = new Button(DisplayContext);
// Create the layout to span two columns
TableRow.LayoutParams params = new TableRow.LayoutParams();
params.span = 2;
newRow2.addView(newButton, 1, params);
newTable.addView(newRow2, rowIndex++);
这个问题是这里简单解决: http://stackoverflow.com/questions/4637233/how-to-set-layout-span-through-code – Derzu 2012-02-13 12:05:23