Baseflow / Baseflow/PhotoView

PhotoView adjust image size to better fit bounds of ImageView

Open
#397 0 comments 6 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.