1
我有一個窗體的表格佈局有兩列 - 一個字段名稱和一個字段值。在某些情況下,字段值是一個清單。我希望「清單」行的行高擴大,以便我可以在列表視圖中看到所有項目。android tablelayout展開行高到列表視圖的內容
以下代碼顯示了一個小垂直可滾動視圖中的listview,其高度與第一列中的字段名稱相同。如何擴大行高以便我可以看到整個列表? (表格單元格中的FrameLayout可以覆蓋圖標或文字)。
// get the table
TableLayout table = FindViewById<TableLayout>(Resource.Id.formTable);
// make a new table row
TableRow row = new TableRow(this);
// add the field name (left column)
TextView rowName = new TextView(this);
rowName.Text = field.Name + ":";
rowName.Gravity = GravityFlags.Right | GravityFlags.CenterVertical;
TableRow.LayoutParams tableLayoutParams = new TableRow.LayoutParams(LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent);
tableLayoutParams.Gravity = GravityFlags.Right | GravityFlags.CenterVertical;
tableLayoutParams.Weight = 1.0f;
tableLayoutParams.Width = 0;
row.AddView(rowName, tableLayoutParams);
// add the field value (right column - in this case, a listview for a checklist)
FrameLayout frameLayout = new FrameLayout(this);
List<string> strings = field.Items.ToList();
ListView listView = new ListView(this);
listView.Adapter = new ListViewFormAdapterCheckList(this, strings);
frameLayout.AddView(listView);
tableLayoutParams = new TableRow.LayoutParams(TableLayout.LayoutParams.WrapContent, TableLayout.LayoutParams.WrapContent);
tableLayoutParams.SetMargins(0, 10, 0, 0);
tableLayoutParams.Width = 0;
row.AddView(frameLayout, tableLayoutParams);