java - Drawing drawable in canvas doesn't work -
i want draw drawable on canvas code doesn't work , don't know why
getresources().getdrawable(r.drawable.allergist).draw(canvas);
i set custom views heigh , width match parent whole screen white , there no drawable on screen
you need load
image
bitmap
:
resources res = getresources(); bitmap bitmap = bitmapfactory.decoderesource(res, r.drawable.allergist);
then make
bitmap mutable
, create canvas on it:
canvas canvas = new canvas(bitmap.copy(bitmap.config.argb_8888, true));
after can draw on canvas.
edit 1
set bounds
drawable
.
drawable d = getresources().getdrawable(r.drawable.allergist); d.setbounds(left, top, right, bottom); d.draw(canvas);
Comments
Post a Comment