Zoomlayout: Back Image to the center after movements

Created on 25 Jun 2020  ·  5Comments  ·  Source: natario1/ZoomLayout

How do I?

I set aligment to none and after some MOVE Actions want toback my image to center (origin position).

Image does not move back with code zoomLayout.setAlignment(Alignment.CENTER); to the center.

How to do it correct?

Version used

Last Version

question

Most helpful comment

@Yahor10 you have to use the move APIs to zoom where you want.
@markusressel please do if you want. We could also maintain a docs page with "recipes", since we can't cover all cases with APIs and we should really encourage people to do calculations and go through a few minutes of thinking, concepts are simple and understanding them will unlock all the possibilities.

All 5 comments

We don't have an API to re-apply the transformation by you can try re-setting the size: zoomLayout.engine.setContainerSize(zoomLayout.width, zoomLayout.height, true). Note the true at the end.

@natario1 what do you think about adding a helper function to the to the api for this use case, like f.ex. moveToCenter(zoom: Float? = null)? It seems like a hard thing to do for newcomers, probably because of the way moveTo uses the left upper corner as a reference, instead of the center of the view.

zoomLayout.engine.setContainerSize(zoomLayout.width, zoomLayout.height, true)
Works better. Effect is sharp still.

How to do it with smooth animation?

@Yahor10 you have to use the move APIs to zoom where you want.
@markusressel please do if you want. We could also maintain a docs page with "recipes", since we can't cover all cases with APIs and we should really encourage people to do calculations and go through a few minutes of thinking, concepts are simple and understanding them will unlock all the possibilities.

Closing this since everything has been said.

Was this page helpful?
0 / 5 - 0 ratings