PhotoView adjust image size to better fit bounds of ImageView
- Dominant language
- Java
- Stars
- 18.8k
- Forks
- 3.9k
- PR merge metrics
- No merged PRs in 30d
Description
I think that this feature is very useful for PhotoView.
When I set an image/drawable/bitmap in ImageView and I would like the PhotoView automatically adjust the image size to fit the bounds of ImageView (without empty space).
I think this is very simple, when I set an image we can compute the scale to fit in the ImageView:
```
int width = drawable.getWidth();
int height = drawable.getHeight();
int ivWidth = imageView.getWidth();
int ivHeight = imageView.getHeight();
float xScale = ((float) ivWidth) / width;
float yScale = ((float) ivHeight) / height;
float scale = (xScale > yScale) ? xScale : yScale;
```
So, scale can be used to fit the image in the ImageView size.
I looked this feature in PhotoView but I didn't find.
[Example](http://imgur.com/GCgmhkw)
Contributor guide
Assessment
This issue has not been assessed yet.