PhotoView fit screen height maintain aspect ratio

941 views Asked by At

I cant scaletype for my PhotoView that lets me pan side to side on an image while being full-screen, without cropping the sides using Photo.ScaleType.CENTER_CROP. How would I go about doing this?

This is what I want (where the user can pan side to side to view the whole image): enter image description here

This is what I get (when using ScaleType.CENTER_CROP, which is closest to what I'm going for but because of the CROP, doesnt allow panning side to side.):

enter image description here

2

There are 2 answers

0
Daniel Arena On BEST ANSWER

I fixed it by using a PhotoViewAttacher like this:

ImageView imageView = (ImageView) findViewById(R.id.preview);
PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(imageView);
photoViewAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP)

and then using an ImageView (id.preview) with the ScaleType in the XML set as Matrix. (otherwise it wont work)

1
mohammadreza khalifeh On

you can use a this ImageViewZoom.

if you don't want to use lib see the codes and try to scale canvas