为什么只有一个ImageView被绘制到我的布局

时间:2016-07-03 08:42:11

标签: android layout imageview android-drawable

我想向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);

不幸的是,只显示了第一个,但第二个没有在屏幕上绘制。我的错是什么?

0 个答案:

没有答案