How to scale background image on canvas according to device size in android -


all have used image background on canvas

canvas.drawbitmap(bitmapfactory.decoderesource(getresources(), r.drawable.help_4, 0, 0, null); 

and large image. can pls. provide me solution image set according device size. i'm new coding detailed explanation appreciated :)

thank you

you're there. need configure bitmapfactory.options variable setting output width , height (based on screen size):

bitmapfactory.options options = new bitmapfactory.options(); display display = getwindowmanager().getdefaultdisplay(); point size = new point(); display.getsize(size); options.outheight = size.x; options.outwidth = size.y; canvas.drawbitmap(bitmapfactory.decoderesource(getresources(), r.drawable.help_4, options)); 

Comments