Reputation: 2148
I am trying to scale a picture drwable which I get from svg-android-library. I can create the drawable but do not get how to scale it.
Here is the code I tried:
Drawable drawable = svg.createPictureDrawable();
int size = 108;
Bitmap img = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(img);
//resize drawable here according to screen width
drawable = new ScaleDrawable(drawable, 0, size*2, size*2).getDrawable();
drawable.setBounds(0, 0, size*2, size*2);
drawable.draw(canvas);
Any suggestions?
Upvotes: 0
Views: 879
Reputation: 1393
I used
Picture picture = svg.getPicture();
and then draw it with a new Rect which will stretch it to fit the new Rect
canvas.drawPicture(picture, newRect);
Upvotes: 3