Skip to content Skip to sidebar Skip to footer

How To Get Setscaletype(imageview.scaletype.fit_center) Effect Using Setscaletype(imageview.scaletype.matrix)

In Android using ImageView and Matrix, I want to scale an image to fit in the display area. Then using pinch, a user can zoom the image. Using setScaleType(ImageView.ScaleType.FIT_

Solution 1:

You need to use mMatrix.setRectToRect and Matrix.ScaleToFit.CENTER with your image coordinates and your view coordinates as the source and destination rectangles.

mMatrix.setRectToRect(new RectF(0,0,mImageView.getMeasuredWidth(),mImageView.getMeasuredHeight()),new RectF(0,0,mImageView.getParent().getMeasuredWidth(),mImageView.getParent().getMeasuredHeight()),Matrix.ScaleToFit.CENTER);

Post a Comment for "How To Get Setscaletype(imageview.scaletype.fit_center) Effect Using Setscaletype(imageview.scaletype.matrix)"