0
我只是試圖在表格佈局中的標題行下添加分隔線,但無論我在layoutparams中設置寬度/高度,視圖佔用了整個頁面。添加視圖到TableLayout佔用整個屏幕
TableLayout tl = (TableLayout)FindViewById(Resource.Id.counted);
TableRow row = new TableRow(this);
TextView itemNumber = new TextView(this);
TextView itemDesc = new TextView(this);
TextView quantity = new TextView(this);
itemNumber.Text = "Item Number";
var inlo = new TableRow.LayoutParams(1);
inlo.SetMargins(10, 10, 30, 10);
itemNumber.LayoutParameters = inlo;
itemDesc.Text = "Item Description";
var idlo = new TableRow.LayoutParams(2);
idlo.SetMargins(10, 10, 30, 10);
itemDesc.LayoutParameters = inlo;
quantity.Text = "Quantity";
var qlo = new TableRow.LayoutParams(3);
qlo.SetMargins(10, 10, 30, 10);
quantity.LayoutParameters = qlo;
View v = new View(this);
v.LayoutParameters = new TableRow.LayoutParams(ViewGroup.LayoutParams.FillParent | 0);
v.SetBackgroundColor(Android.Graphics.Color.White);
row.AddView(itemNumber);
row.AddView(itemDesc);
row.AddView(quantity);
tl.AddView(row);
tl.AddView(v);
v,其白色背景佔據整行下方的屏幕。 ????
什麼是你的表的父母?你能粘貼你的xml佈局嗎? – 2011-12-30 21:05:55
這只是一個空表佈局。 TableLayout> –
jmease
2011-12-30 21:14:14
嘗試將'android:layout_height =」fill_parent「'更改爲'wrap_content'或將表格放置在另一個佈局中。 – 2011-12-30 21:17:54