我想向RelativeLayout添加多个显示可绘制的ImageView。这个简短的例子应该添加两个这样的ImageViews:
//get drawable
Drawable oval = this.getResources().getDrawable(R.drawable.circle);
// set color
oval.setColorFilter(imgEl.getColor(), PorterDuff.Mode.SRC_ATOP);
// create new image view
ImageView imageView = new ImageView(this);
//set drawable and add to layout
imageView.setImageDrawable(oval);
imageView.setLayoutParams(new RelativeLayout.LayoutParams(100,100));
imageView.setPadding(0,0,0,0);
mLayout.addView(imageView);
//get drawable
oval = this.getResources().getDrawable(R.drawable.circle);
// set color
oval.setColorFilter(imgEl.getColor(), PorterDuff.Mode.SRC_ATOP);
// create new image view
imageView = new ImageView(this);
//set drawable and add to layout
imageView.setImageDrawable(oval);
imageView.setLayoutParams(new RelativeLayout.LayoutParams(100,100));
imageView.setPadding(200,200,0,0);
mLayout.addView(imageView);
不幸的是,只显示了第一个,但第二个没有在屏幕上绘制。我的错是什么?