Image zoom in and zoom in ImageView

Source: Internet
Author: User

Get the bitmap to zoom out.

Obitmap = Bitmapfactory.decoderesource (This.getresources (), r.drawable.ic_launcher);
Obitmap1 = Bitmapfactory.decoderesource (This.getresources (), R.drawable.cazhao);
Zooming in and out
Bitmap = a (Obitmap);
Bitmap1 = A (OBITMAP1);
// -----------


IV = (ImageView) Findviewbyid (R.id.imagev);
Iv1 = (ImageView) Findviewbyid (R.ID.IMAGEV1);
Iv.setimagebitmap (bitmap);
Iv1.setimagebitmap (BITMAP1);

Public Bitmap A (Bitmap OBP) {
Bitmap Rbitmap;
Full Screen high
WindowManager wm = (WindowManager) This
. Getsystemservice (Context.window_service);

The new picture is high and you can set it yourself. I am proportionally, take pictures of the high.
int ny = Wm.getdefaultdisplay (). GetHeight ()/8;

The height of the source picture
int oy = Obp.getheight ();

Here we calculate the scale of scaling, you can set the scale directly below CreateBitmap yourself
float c = ny * 1.0F/OY;
Matrix matrix = new Matrix ();
Matrix.prescale (c, c);
Get it out.
Rbitmap = Bitmap.createbitmap (OBP, 0, 0, Oy, Oy, Matrix, true);


return rbitmap;

}

Image zoom in and zoom in ImageView

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.