How to resize Image in Android?

Jignesh Ansodariya picture Jignesh Ansodariya · May 2, 2012 · Viewed 195.3k times · Source

I am creating an application and want to setup a gallery view. I do not want the images in the gallery view to be full size. How do I resize images in Android?

Answer

goodm picture goodm · May 2, 2012

Try:

Bitmap yourBitmap;
Bitmap resized = Bitmap.createScaledBitmap(yourBitmap, newWidth, newHeight, true);

or:

resized = Bitmap.createScaledBitmap(yourBitmap,(int)(yourBitmap.getWidth()*0.8), (int)(yourBitmap.getHeight()*0.8), true);