PhotoView fit screen height maintain aspect ratio

不羁岁月 提交于 2020-05-16 05:37:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!