0

How can I draw an ImageView from the OnDraw() method? canvas.() does not have to call a resource?

I am trying to do this

        @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        imageBack = BitmapFactory.decodeResource(getResources(), R.drawable.background);    
        canvas.drawBitmap(imageBack, (x /2)-15 ,y /2, null); 
        //touchEvents();
        ImageView image1 = (ImageView)findViewById(R.id.ImageView01);



    } 
user710502
  • 11,181
  • 29
  • 106
  • 161

1 Answers1

1

Hi have improved you onDraw method plz check

 @Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    imageBack = BitmapFactory.decodeResource(getResources(), R.drawable.background);    
    imageBack.setBounds(0,0,getWidth(),getHeight());
    imageBack.draw(canvas);

} 

you are not very much clear. so if you find any diffuculty you can add comment to my post

Sunil Pandey
  • 7,042
  • 7
  • 35
  • 48