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

Adding View to ScalingLayout #365

Closed azizbekian closed 8 years ago

azizbekian commented 8 years ago

In the "...add a down-sampled image beneath the tile layer?" you showed how to add an ImageView to TileView. What I need is adding a layout, so that it can be zoomed. Thus I tried adding my layout to ZoomPanLayout instead of TileView, which works fine, now my layout gets zoomed in/out. But the tiles are not being displayed. I guess they are being shown beneath of my added layout.

How can I achieve this effect? I want my layout (which is filled by ImageViews) to be shown and when zoomed in the tiles loaded on top of this layout.

moagrius commented 8 years ago

if you want a layer beneath the tiles use addViewAt(0, view);

moagrius commented 8 years ago

also, TileView inherits from ZoomPanLayout, they're not different instances

moagrius commented 8 years ago

is this resolved?

azizbekian commented 8 years ago

if you want a layer beneath the tiles use addViewAt(0, view);

Cannot seem to find such an API. Which class has this method?

azizbekian commented 8 years ago

also, TileView inherits from ZoomPanLayout, they're not different instances

When adding LinearLayout filled horizontally with multiple ImageViews as a first child of TileView (aka TileView.addView(myLinearLayout, 0)), when zooming the TileView, images in LinearLayout get stretched, whereas when this LinearLayout is added to ZoomPanLayout the zoom works perfectly fine.

moagrius commented 8 years ago

I'm not sure what you mean. There is only one ZoomPanLayout which is also the TileView, unless you're adding your own.

azizbekian commented 8 years ago

Sorry for confusion. I meant ScalingLayout.

tileView.getScalingLayout().addView(linearLayout, 0);

This way the zooming works fine. But if I add the linearLayout as a child of tileView, then zooming stretches the images that are inside of this linearLayout.

Now, what I want is to have this linearLayout as a first layer, and when zoomed - layer two loaded. But this way layer two is beneath the linearLayout, so tiles are not seen when zoomed.

moagrius commented 8 years ago

OK. There's a built-in ScalingLayout right above the tiles: https://github.com/moagrius/TileView/blob/master/tileview/src/main/java/com/qozix/tileview/TileView.java#L113

This one is automatically synced with the TIleView's scale. You can move this one to beneath the tiles, with something like:

View scalingLayout = tileView.getScalingLayout();
tileView.removeView(scalingLayout);
tileView.addView(0, scalingLayout);

Or, you could make your own ScalingLayout, add that at the first level, but then you'd have to sync the scale with tileview yourself (although that's pretty easy).

azizbekian commented 8 years ago

Thank you, @moagrius , this works pretty nice!

moagrius commented 8 years ago

:thumbsup: