我正在尝试在新行中显示每个内容(图像视图和文本视图),但我无法成功。我正在以编程方式执行此操作,这是我的代码。
RelativeLayout grp=new RelativeLayout(this);
grp.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
grp.setPadding(10, 10, 10, 10);
TextView test=new TextView(this);
test.setPadding(15, 15, 15, 15);
test.setText(Html.fromHtml("<p>text here</p>"));
LinearLayout ln=new LinearLayout(this);
ImageView img=new ImageView(this);
img.setImageResource(R.drawable.imageA);
img.setFadingEdgeLength(10);
ln.addView(img);
ln.addView(test);
ln.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.FILL_PARENT));
LinearLayout ln0=new LinearLayout(this);
grp.addView(ln);
TextView test1=new TextView(this);
test1.setPadding(15, 15, 15, 15);
test1.setText(Html.fromHtml("<p>text here</p>"));
LinearLayout ln1=new LinearLayout(this);
ImageView img1=new ImageView(this);
img1.setImageResource(R.drawable.imageB);
img1.setFadingEdgeLength(10);
ln1.addView(img1);
//ln1.setPadding(10, 10, 10, 10);
ln1.addView(test1);
ln1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.FILL_PARENT));
grp.addView(ln1);
setContentView(grp);
我该怎么办?