2
我有以下在我的活性,其成功地顯示數據的3列(會有多達10行,從而for循環):分配重量至3個TextViews與TableLayout.LayoutParams
for (int i=0;i<10;i++)
{
TableRow tr = new TableRow(this);
TextView tv0 = new TextView(this);
TextView tv1 = new TextView(this);
TextView tv2 = new TextView(this);
TableRow.LayoutParams trlp = new TableRow.LayoutParams();
trlp.span = 3;
trlp.weight = 1;
tr.setLayoutParams(trlp);
tv0.setText("" + debtName[i]);
tv1.setText("" + debtAmount[i]);
tv2.setText("" + debtPayment[i]);
tr.addView(tv0);
tr.addView(tv1);
tr.addView(tv2);
tl.addView(tr);
}
我想由於有一個硬編碼到佈局的標題行,所以它們被均衡加權。 「trlp.weight = 1;」並沒有改變它不存在的時候。
我在尋找的是一種讓tv0,tv1,tv2 TextViews均勻分佈(水平)的方法。
也可對照,我在API 12