-2

I'm currently working on an Android app. I have a canvas onto which the user will draw something. I need to have a picture as the background of this canvas.

I already managed to import a pic and set it as the background using

mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.my_background_pic));

However, the picture appears ten times bigger than the screen.

Is it possible to keep the picture resized, so it fills the canvas and not more?


Also, later I will need to add other things to the activity. The canvas will not be the only thing on the screen, so I need the picture to be the size of the canvas, and not the screen.

Thanks a lot.

C. Crt
  • 357
  • 2
  • 17
  • Nevermind I found it: `canvas.drawBitmap(bitmap, null, new RectF(0, 0, canvasWidth, canvasHeight), null);` By Kai at https://stackoverflow.com/a/27466127/8205282 – C. Crt Mar 11 '18 at 11:05

1 Answers1

0

Nevermind I found it:

canvas.drawBitmap(bitmap, null, new RectF(0, 0, canvasWidth, canvasHeight), null);

By Kai at stackoverflow.com/a/27466127/8205282

C. Crt
  • 357
  • 2
  • 17