ZoomableImageView icon indicating copy to clipboard operation
ZoomableImageView copied to clipboard

Maintain scale and pan after changing image

Open league opened this issue 12 years ago • 1 comments

Thanks for ZoomableImageView… it was easy to drop into my application and works great.

There's one small feature I'd like, though. I have small embedded (non-zoomable) images in my layout, and the user touches them to open a zoomable detail view. I'm loading the images from the web, so there can be a delay before the higher-resolution image appears. So I first create a ZoomableImageView with the low-res image that is already available. Once the new image is downloaded and ready, I use setImageBitmap() to replace it.

This works and looks great, as long as the user hasn't zoomed or panned yet. If the user already zoomed or panned, it gets set back to the initial size when the new bitmap arrives. (The onMeasure hook calls resetImage.) And then it behaves a little strangely because currentScale is not set back to 1.0 in resetImage.

With a small modification to resetImage, I was able to fix the issue of matching the same scale and "focal position" we were at before the new image arrived. I'll shortly fork and commit that part. The tiny problem that remains is matching the position within the image if the user also dragged it around.

league avatar Aug 01 '13 18:08 league

Okay, when you have some time, I'd be thrilled if you could look at https://github.com/league/ZoomableImageView/commits/master

That's my test program (in nomaven) and partial fix, but it doesn't maintain position after zoom and drag. I imagine it's a matter of updating the focus to correspond to each drag, but the few things I tried along that line didn't get the position right. Thanks.

league avatar Aug 01 '13 18:08 league