for (int i = 0; i <10; i++) {
int count = i;
iv_album[i] = new ImageView(this);
iv_album[i].setImageDrawable(this.getResources().getDrawable(R.drawable.desimg));
iv_album[i].setPadding(0, 5, 5, 0);
iv_album[i].setId(i); // BELOW id 0 doesn't work
iv_album[i].setScaleType(ImageView.ScaleType.FIT_XY);
params1 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, 230);
if((i>0))
{
params1 = new RelativeLayout.LayoutParams(
150, 200);
if (imgtype[i].equalsIgnoreCase("medium") )
{
//iv_album[i]
// Picasso.with(getApplicationContext()).load("http://aflaree.com/yoday/Images/b.jpg").into(iv_album[i]);
params1 = new RelativeLayout.LayoutParams(
150, 200);
//params1.addRule(RelativeLayout.BELOW, iv_album[i - 1].getId());
params1.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, RelativeLayout.TRUE);
params1.addRule(RelativeLayout.BELOW, iv_album[i - 1].getId());
mainlayout.addView(iv_album[i], params1);
//mainlayout.addView(iv_album[i], params1);
Log.d("count:", "" + count);
} else if (imgtype[i].equalsIgnoreCase("large"))
{
params1 = new RelativeLayout.LayoutParams(
250, 200);
//params1.addRule(RelativeLayout.BELOW, iv_album[i - 1].getId());
params1.addRule(RelativeLayout.RIGHT_OF,iv_album[i - 1].getId());
//Picasso.with(getApplicationContext()).load("http://www.aflaree.com/yoday/Images/113/mm.jpg").into(iv_album[i]);
//mainlayout.addView(iv_album[i], params2);
mainlayout.addView(iv_album[i], params1);
Log.d("count:", "" + count);
} else if (i % 5 == 0)
{
Log.d("count:", "" + count);
params1 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT, 200);
// Picasso.with(getApplicationContext()).load("http://www.aflaree.com/yoday/Images/117/res30.png").into(iv_album[i]);
//params3.addRule(RelativeLayout.ALIGN_PARENT_START, RelativeLayout.TRUE);
params1.addRule(RelativeLayout.ALIGN_START);
params1.addRule(RelativeLayout.BELOW, iv_album[i - 1].getId());
mainlayout.addView(iv_album[i], params1);
//mainlayout.addView(iv_album[i], params3);
}
else
{
// Picasso.with(getApplicationContext()).load("http://www.aflaree.com/yoday/Images/113/mm.jpg").into(iv_album[i]);
params1.addRule(RelativeLayout.BELOW, iv_album[i - 1].getId());
mainlayout.addView(iv_album[i], params1);
}
}
else {
//Picasso.with(getApplicationContext()).load("http://www.aflaree.com/yoday/Images/113/ca.jpg").into(iv_album[i]);
params1.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
params1.addRule(RelativeLayout.ALIGN_START,RelativeLayout.TRUE);
mainlayout.addView(iv_album[i], params1);
}
`我有三种类型的图像阵列,如小型,中型和大型。如果第一个图像类型小于数组意味着我必须在屏幕左侧显示图像,然后是下一个图像类型,如果它是中等意味着它将来到右边的小图像然后下一个图像如果它很大意味着它将低于中小图像。并且方式2是如果第一图像类型大则意味着它必须以宽度填充屏幕而不是高度。高度必须像200一样恒定。每行都有不同的行和列。我想尝试像Windows启动屏幕。怎么解决这个问题?提前谢谢。