I am setting a drawable for a progress dialog (pbarDialog
) but my issue is I want to resize the drawable each time but can\'t figure out how.
Here is so
Here's where I ended up, thanks in part to Saad's answer:
public Drawable scaleImage (Drawable image, float scaleFactor) {
if ((image == null) || !(image instanceof BitmapDrawable)) {
return image;
}
Bitmap b = ((BitmapDrawable)image).getBitmap();
int sizeX = Math.round(image.getIntrinsicWidth() * scaleFactor);
int sizeY = Math.round(image.getIntrinsicHeight() * scaleFactor);
Bitmap bitmapResized = Bitmap.createScaledBitmap(b, sizeX, sizeY, false);
image = new BitmapDrawable(getResources(), bitmapResized);
return image;
}