How can I add separating lines between my TableRows that are created programmatically?

雨燕双飞 提交于 2019-11-28 23:16:28
View v = new View(this);
v.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, 1));
v.setBackgroundColor(Color.rgb(51, 51, 51));
tr.addView(mTvDate);
tr.addView(mTvResult);

tl.addView(tr); 
tl.addView(v);

Here I'm creating a view that is one pixel high with a specific background color. This works for me.

Thanks to Madhusuthanan for this. I spent a while searching for how to do this to simply separate TextViews with a horizontal line. I was creating my view programmatically (without using a Table layout). Here is what I came up with based on the above answer:

View line = new View(this);
line.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 1));
line.setBackgroundColor(Color.rgb(51, 51, 51));
layout.addView(line);

Simple! Hope this helps someone else!

You can use Listview that will be easiler and better than doing this.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!