2011-12-30 91 views
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,其白色背景占据整行下方的屏幕。 ????

+0

什么是你的表的父母?你能粘贴你的xml布局吗? – 2011-12-30 21:05:55

+0

这只是一个空表布局。 jmease 2011-12-30 21:14:14

+0

尝试将'android:layout_height =”fill_parent“'更改为'wrap_content'或将表格放置在另一个布局中。 – 2011-12-30 21:17:54

回答

0

只是决定使用字符串来强调我的列标题,而不是试图在第一行下放置一行。

相关问题