我使用表格布局将数据显示为表格,但我想要一个包含用户定义列和带边框的行的表格.建议?
我有一个在Android项目中以编程方式创建的TableLayout.只要从数据库中获取更多行,我就会不断添加TableRows.现在我想在TableRows之间添加分隔线,如边框.
在我从XML静态创建的另一个TableLayout中,我使用View作为分隔符,使用style.xml样式.
我尝试将一个View添加到tablelayout,如下所示:
View v=new View(this);
v.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
v.setBackgroundResource(R.drawable.rowseparator_shape);
tr.addView(mTvDate);
tr.addView(mTvResult);
tl.addView(tr);
tl.addView(v);
Run Code Online (Sandbox Code Playgroud)
但它只在所有收集的TableRows之后添加一次.为每个tr添加一个View的智能方法是什么?或者我应该一起使用其他东西?
我有一个问题,如何以编程方式在Android的tablelayout中提供单元格边框.
这是我的代码:
TableLayout table = (TableLayout)findViewById(R.id.linear_Layout_List);
TableRow row=null;
TableRow row1=null;
Button label = null;
int size=items.size();
for (int i = 0; i < size-2; i+=3)
{
row = new TableRow(SearchGridActivity.this);
row.setId(100+i);
for(j=0;j<3;j++)
{
/*TableLayout.LayoutParams tableRowParams=
new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
int leftMargin=10;
int topMargin=2;
int rightMargin=10;
int bottomMargin=2;
tableRowParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
row.setLayoutParams(tableRowParams);*/
if(count_img!=NUM_RESULTS)
{
//row.setPadding(10, 2, 10, 0);
View v = View.inflate(this, R.layout.tablecell, null);
LinearLayout lay = (LinearLayout)v.findViewById(R.id.linear_table);
/*MarginLayoutParams layoutParams = new MarginLayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(30, 20, 30, 0);*/
final ImageView …Run Code Online (Sandbox Code Playgroud) 好吧,我的应用程序有一个包含很多表格的tablelayout,但我怎么能在它们之间划分呢?例如:一个桌子,在那之后是一条线,在另一个桌子之后,依此类推.那有一些属性吗?