To scale images use following
Bitmap bitmap = BitmapFactory.decodeResource(
getResources(), R.drawable.app_bg);
scaledBitmap = Bitmap.createScaledBitmap(bitmap, width, height, true);
then assign this scaledBitmap
to any ImageView
or any other View
. This will scale the original Bitmap
to the requested width
and height
. To get width and height of the device screen use following
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;
EDIT
In order to handle MemoryLeakException
add scaledBitmap.recycle()
after using this Bitmap
.