moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

Hi, is there a zoomin and zoomout method? #49

Closed wangvsa closed 10 years ago

wangvsa commented 10 years ago

Hi @moagrius , thank you very much for providing a such excellent widget.

Is there a method like zoomin or zoomout? I thought it might be handy to use but i could not find one.

wangvsa commented 10 years ago

if shouldScaleToFit is set to true, can i get the minimum value of scale?

moagrius commented 10 years ago

Hi @wangvsa , glad you find the widget useful.

Is there a method like zoomin or zoomout?

I think you're looking for TileView.setScale.

if shouldScaleToFit is set to true, can i get the minimum value of scale?

Not sure why, but I didn't provide getters for min or max scales, and the members are private. It wouldn't be a big deal to add those methods, and I can so so with the next commit if that'd be helpful. shouldScaleToFit just flags whether the tiled image should ever show empty space or not ("true" means do not show empty space).

wangvsa commented 10 years ago

@moagrius thank you again

How can i get the position of the center point? Because I want to scale the image without moving its center.

public void zoomin() {
    tileView.scale(tileView.getScale()+0.25);
    tileView.moveToAndCenter(originCenter.x, originCenter.y)
}
moagrius commented 10 years ago

Normal view methods can be used to maintain scroll position, but it can be kind of a hassle. getScrollX/Y() gives the scroll position, which you can then offset by half of getWidth/Height().

smoothScaleTo does this automatically.

ZoomPanLayout handles most of this kind of thing internally, but you can get some hints. Try the maintainScrollDuringPinchOperation and maintainScrollDuringScaleTween methods.

wangvsa commented 10 years ago

@moagrius Thanks for the clear explanation! I'll check it out soon.

moagrius commented 10 years ago

HTH, GL