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

Scroll outside of bounds #463

Closed Derpalus closed 6 years ago

Derpalus commented 6 years ago

Hello again, more questions!

I'd like to be able to scroll past the bounds of the image. Like if I'm zoomed in so the image is covering the entire screen, there is no way to scroll past the edge of the image.

I can set up so I can zoom out past the edges of the image using setMinimumScaleMode and setScaleLimits, but I still haven't figured out how (if even possible) to override the scrolling?

moagrius commented 6 years ago

getConstrainedScrollX/Y: https://github.com/moagrius/TileView/blob/master/tileview/src/main/java/com/qozix/tileview/widgets/ZoomPanLayout.java#L579 https://github.com/moagrius/TileView/blob/master/tileview/src/main/java/com/qozix/tileview/widgets/ZoomPanLayout.java#L591

Derpalus commented 6 years ago

I'm not quite sure I understand what you mean I should do? Should I fork it? In that case it seems like I should perhaps change the values that getScrollMinX/Y and getScrollLimitX/Y provide.

moagrius commented 6 years ago

you can subclass it and override those methods to return different values. e.g., instead of a minimum of 0, you could have a minimum of -1000

Derpalus commented 6 years ago

Thanks for the help!

moagrius commented 6 years ago

NP, let us know how it goes

tkrz commented 6 years ago

I have to do the same thing, subclassing is not a problem, but how i should supply modified class to TileView?

Derpalus commented 6 years ago

I have made a pull request of my solution. Don't know if it's good enough but if mogarius accepts it then you can use it as well without having to make your own changes.

moagrius commented 6 years ago

@tkrz As @Derpalus mentioned, he's submitted a PR, which I suspect will be accepted in a few days, but as to your question:

I have to do the same thing, subclassing is not a problem, but how i should supply modified class to TileView?

You make a subclass like MyTileView, then use that instead of a normal TileView.

moagrius commented 6 years ago

the latest release offers this feature