Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to reduce large image size to thumbnail size in android

in my app, i have large images, i display it in an image view by hard code the size as 60 X 60 dp. how to reduce the image size as image thumb nail size in android. is there programmatic way. because suppose i run my app in various resolution size design layout may get differ. my need is if i run my app in any resolution device image size should not get differ. how to do that in android. please help me.

i hard code image by the following code.

  <ImageView android:id="@+id/img" android:layout_width="60dp"
     android:layout_height="60dp"
    android:layout_centerVertical="true" />
like image 510
M.A.Murali Avatar asked Jun 07 '11 12:06

M.A.Murali


People also ask

How do I make thumbnails bigger on Android?

Well, there's a way to do just that. All you have to do is open your Gallery app and pinch to zoom until you see full-size, uncropped thumbnails. Depending on your current settings, you may have to pinch to zoom a few times before you hit the max thumbnail size.


1 Answers

Most simple way is

int h = 48; // height in pixels
int w = 48; // width in pixels    
Bitmap scaled = Bitmap.createScaledBitmap(largeBitmap, h, w, true);

and detailed This is called the image scaling

This will help you http://zerocredibility.wordpress.com/2011/01/27/android-bitmap-scaling/

like image 59
Rohit Mandiwal Avatar answered Oct 21 '22 20:10

Rohit Mandiwal