Reputation: 839
How can I apply zoom control in an ImageView
dynamically? My minimum SDK version is 1.6. I tried most of the samples but in all those an image in the ImageView
is set on Zoom-in and Zoom-out. I want to Zoom-in and Zoom-out an ImageView
. I want to increase ImageView
width and height while Zoom-in and reduce ImageView
width and height while Zoom-out. Can any one suggest a solution?
Upvotes: 0
Views: 456
Reputation: 763
yes this is the code to increase the size
140 is the factor by which image is mulitplied maintaining the height to width ratio
you can change this as you like
Bitmap originalBitmap = BitmapFactory.decodeFile(IssueDataHandler.CONTENT_LOCAL_PATH+"/"+coverImageName.trim());
Bitmap bitmap=originalBitmap;
if (bitmap !=null) {
int h = bitmap.getHeight();
int w = bitmap.getWidth();
h = 140*h/w;
w = 140;
bitmap = Bitmap.createScaledBitmap(bitmap, w, h, true);
img.setImageBitmap(bitmap);
}
Upvotes: 1