我以编程方式使用相对布局。它有多个文本视图,但它显示水平而不是垂直。我如何以编程方式获取它们作为段落视图?
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
int x=10;
int y=30;
for(int i=0;i<arrayList.size();i++)
{
String str=arrayList.get(i);
int strLength=arrayList.size();
if(arrayList.get(i).equals("Name")){
y=y+10;
x=65;
}
else
{
x=x+strLength+60;
}
//tv=(TextView) findViewById(R.id.tv1);
tv=new TextView(this);
tv.setText(arrayList.get(i).toString());
tv.setPadding(x, y, 0, 0);
layout.addView(tv, params);
}
scroll.addView(layout);
this.setContentView(scroll);