0
我想將一個imageview
放在另一個上。我想放在上面的imageview
放在下面。如何將一個imageview放在另一個上?
這裏是我的代碼:
for (int i = 1; i <= numberofuploads; i++) {
if (i == 1) {
relativeframe1 = new RelativeLayout(this);
RelativeLayout.LayoutParams paramslayout1 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT/2,
RelativeLayout.LayoutParams.MATCH_PARENT);
paramslayout1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
relativeframe1.setLayoutParams(paramslayout1);
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(
pxrparams1a, pxrparams1b);
imgvwphoto1 = new ImageView(this);
imgvwphoto1.setId(1);
imgvwphoto1.setAlpha(500);
imgvwphoto1.setBackgroundResource(R.drawable.plusicon3);
// params1.setMargins(0, 90, 100, 40);
params1.setMargins(left1, top1, right1, bottom1);
imgvwphoto1.setLayoutParams(params1);
relativeframe1.addView(imgvwphoto1);
imgvwphoto1.setScaleType(ScaleType.MATRIX);
imgvwphoto1.setOnTouchListener(this);
RelativeLayout.LayoutParams paramscomponent1 = new RelativeLayout.LayoutParams(
irpc1, RelativeLayout.LayoutParams.MATCH_PARENT);
paramscomponent1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
imgvwcomponent1 = new ImageView(this);
imgvwcomponent1.setAlpha(0);
imgvwcomponent1 .setBackgroundResource(R.drawable.leftpartdoubleheartframe);
imgvwcomponent1.setBackgroundResource(componentname.getImagename());
imgvwcomponent1.setLayoutParams(paramscomponent1);
relativeframe1.addView(imgvwcomponent1);
relativeframe.addView(relativeframe1);
} else {
relativeframe2 = new RelativeLayout(this);
RelativeLayout.LayoutParams paramslayout2 = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT/2,
RelativeLayout.LayoutParams.MATCH_PARENT);
paramslayout2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
relativeframe1.setLayoutParams(paramslayout2);
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(
pxrparams2a, pxrparams2b);// 106.67dp, 120dp
imgvwphoto2 = new ImageView(this);
imgvwphoto2.setId(2);
imgvwphoto2.setAlpha(500);
imgvwphoto2.setBackgroundResource(R.drawable.plusicon3);
// params2.setMargins(165, 90, 0, 40);
params2.setMargins(left2, top2, right2, bottom2);
imgvwphoto2.setLayoutParams(params2);
relativeframe2.addView(imgvwphoto2);
imgvwphoto2.setScaleType(ScaleType.MATRIX);
imgvwphoto2.setOnTouchListener(this);
RelativeLayout.LayoutParams paramscomponent2 = new RelativeLayout.LayoutParams(
irpc2, RelativeLayout.LayoutParams.MATCH_PARENT);// 103.33dp
paramscomponent2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
imgvwcomponent2 = new ImageView(this);
imgvwcomponent2.setAlpha(500);
imgvwcomponent2
.setBackgroundResource(R.drawable.rightpartdoubleheartframe);
imgvwcomponent2.setLayoutParams(paramscomponent2);
relativeframe2.addView(imgvwcomponent2);
relativeframe.addView(relativeframe2);
}
}
上加號圖標的點擊,圖像上載該imgvwphoto,是與心臟支架overlaping,我希望它只是心臟框架中進行查看。不在心臟框架之外。
爲什麼把一個在其他?你爲什麼想要。兩個ImageView重疊? – pskink
使用framelayout而不是相對 –
兩個圖像瀏覽的兩個照片上傳... – user2769256