我想在Android中平分兒童中的TableRow空間。這是我迄今完成的屏幕。 Android中平分TableRow空間的代碼
我希望「文本1文本1文本1」的行佔用相等的空間量。我想從java代碼中完成。我的java代碼如下:
public class History extends Activity implements View.OnClickListener {
int counter=0;
TableLayout TL ;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.history);
Button b1 = (Button) findViewById(R.id.Button01);
b1.setOnClickListener(this);
}
public void onClick(View arg0) {
TableLayout TL = (TableLayout) findViewById(R.id.table_layout);
TableRow row = new TableRow(this);
counter++;
TextView t = new TextView(this);
t.setText("text " + counter);
TextView t1 = new TextView(this);
t1.setText("text " + counter);
TextView t2 = new TextView(this);
t2.setText("text " + counter);
// add the TextView and the CheckBox to the new TableRow
row.addView(t);
row.addView(t1);
row.addView(t2);
TL.addView(row,new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
}
}
我想實現以下屏幕。 我能做些什麼來實現我的目標?
'TableLayout'有一個'setStretchAllColumns()'方法。 – Luksprog
您可能會發現此鏈接有幫助 http://stackoverflow.com/a/4577669/1295906 – Smittey