问题
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):
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.):
回答1:
you can use a this ImageViewZoom.
if you don't want to use lib see the codes and try to scale canvas
回答2:
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)
来源:https://stackoverflow.com/questions/46114143/photoview-fit-screen-height-maintain-aspect-ratio