tags:

views:

548

answers:

1

I am having image large size image, at run time i want read image from storage and scale it so that its weight and size will be reduce and i can use it as thumbnail when user click on thumbnail i will display full size image.

A: 

Use BitmapFactory.decodeFile(...) to get your Bitmap object and set it to an ImageView with ImageView.setImageBitmap().

On the ImageView set the layout dimensions to something small, eg:

android:layout_width="66dip" android:layout_height="48dip"

Add an onClickListener to the ImageView and launch a new activity, where you display the image in full size with

android:layout_width="wrap_content" android:layout_height="wrap_content"

or specify some larger size.

Jim Blackler
When having multiple images you should consider scaling it down to the thumb size beforehand. otherwise that could slow down the performance when moving the set.
Soulreaper
Indeed, and to do that you would use Bitmap.createScaledBitmap(originalBitmap, newWidth, newHeight, false);
Jim Blackler
dones following method also reduce the weight of the image ? Bitmap.createScaledBitmap(originalBitmap, newWidth, newHeight, false)
Faisal khan