Zoom out to show whole image
It would be very useful to add a feature to the widget which allows zooming out enough to show the entire image.
Currently the minimum zoom (zoom out) is capped to never show areas outside the specified image. However this also makes it impossible to zoom out far enough to see the whole image (well unless your image aspect ratio perfectly matches the views aspect ratio, which is rare).
The UX would be dramatically worsened in my opinion if we show whitespace, which would be required to show the entire map.
You can achieve this same effect by placing a TileView instance in your own layout (e.g., put a TileView in a RelativeLayout, have it match the largest dimension and center across the smaller dimension).
If I implement this by adding setMinimumZoomMode(zoomMode) which would support the existing behaviours (fill and no minimum zoom) as well as the new one (fit), would you potentially accept it?
is what you're describing different from setShouldScaleToFit?
Yes, it is. The setShouldScaleToFit is basically what is typically spoken of as "scale to fill while maintaining aspect ratio", even the documentation of that function speaks of fill, while fit is typically used meaning fit this image into this rectangle, i.e. show the whole image.
- fill = current behaviour with setShouldScaleToFit(true)
- off = current behaviour with setShouldScaleToFit(false)
- fit = new behaviour where the image would be scaled to fit the viewport.
I would prefer to use the more widely used terminology as described above, but more importantly I just want this feature :)
So I'm not really clear on what the new feature would do. The original post said:
It would be very useful to add a feature to the widget which allows zooming out enough to show the entire image.
Currently, you can zoom out to see the entire image by setShouldScaleToFit(false).
That said, if you have a new feature that you think would be useful the user base at large, and is not a breaking change, conforms to code style, etc, then yes I'd potentially accept it.
Ok, re-reading my initial post, I can see I wasn't clear enough. Sorry about that.
So I'd like a bounded minimum zoom, which would stop zooming out once the entire image is shown.
perhaps adding a new API called setMinimumZoomMode(MinimumZoomMode mode); where
public enum MinimumZoomMode {
OFF,
FILL,
FIT
}
Then the old api (deprecated I hope) would be implemented as
public void setShouldScaleToFit( boolean shouldScaleToFit ) {
if(shouldScaleToFit) {
setMinimumZoomMode(MinimumZoomMode.FILL);
} else {
setMinimumZoomMode(MinimumZoomMode.OFF);
}
}
Would the visible area be centered? Top-left?
Centered :)
centered horizontally or vertically, depending on which is needed.
I see potential value. I would not deprecate setScaleToFit, but what happens under the covers is not important to me (your example would be fine). Feel free to fork and PR. Please try to match code style (naming conventions, whitespace, etc). Include javadoc where appropriate. Bump versions in gradle and readme. Etc.
Thanks for pitching in.
Ok. I'll take a stab at implementing this.
Cool, looking forward to seeing it. Thanks again.
@mkv123 Are you needing something like this? This is TileView in what I would call "scaled to fit" instead of "scaled to cover" (this is currently called "scaled to fit" however in the current implementation). I have also got it centered in screen. See screenshot below (this image is TileView)
.

I've said to Mike previously, I've been meaning to fork TileView and add these changes in. Ill try see if I get some time tonight.
Yup, exactly that. Actually I implemented it as well, but ran into some issues where I wasn't able to get it to work unless the mode was set as the default. Something to do with the initial scaling calculations, but I also ran out of time trying to debug the issue. Since the hacked version delivered what was needed (without support for the original mode) I needed to move to other things.
I added a PR to allow different scale modes and added centering: https://github.com/moagrius/TileView/pull/318
this should be fixed in 2.1.8, re-open if your issue is not resolved
ref https://github.com/moagrius/TileView#scaling