1

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

Daniel Arena
  • 117
  • 11

2 Answers2

0

you can use a this ImageViewZoom.

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

mohammadreza khalifeh
  • 1,510
  • 2
  • 18
  • 32
  • I tried using the library but it isn't the same, because once the photo is zoomed in, it can be zoomed back out. And the library codes didn't work either because they use the height of the image as a drawable, whereas I am just loading the image into the PhotoView using Glide. Thank you for sharing that library though, I think it could be part of making it work. – Daniel Arena Sep 10 '17 at 01:25
0

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)

Daniel Arena
  • 117
  • 11