Android 已调用onDraw(),但未显示任何内容

Android 已调用onDraw(),但未显示任何内容,android,ondraw,Android,Ondraw,我需要在屏幕上画一些矩形,在背景图像上。为此,我创建了以下类: public class MyImageView extends ImageView { public MyImageView(Context context) { super(context); } public MyImageView(Context context, AttributeSet attrs) { super(context,attrs); }

我需要在屏幕上画一些矩形,在背景图像上。为此,我创建了以下类:

public class MyImageView extends ImageView {

    public MyImageView(Context context) {
        super(context);
    }

    public MyImageView(Context context, AttributeSet attrs) {
        super(context,attrs);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        System.out.println("draw");
         Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
         canvas.drawColor(Color.BLACK);
         canvas.drawBitmap(background, 0, 0, null);
    }

}
在活动的xml文件中,我放了:

<com.www.MyImageView android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_marginLeft="150dip"
        android:layout_marginTop="50dip">


logCat
中,我从
onDraw()
方法中获得消息,但没有显示任何内容。我的问题在哪里?我错过了什么?

只要试试canvas.drawBitmap(背景,0,0,new Paint())

将包装内容更改为填充内容谢谢..这就是问题:)很高兴听到问题解决了:)