subsampling-scale-image-view
subsampling-scale-image-view copied to clipboard
ChangeImageTransform does not work between ImageView and subsampling-scale-image-view
I've create a sample project to show this problem: https://github.com/flykule/ScaleImgSharedElementDemo As you can see,when I come back from this scale view to image view,the change image transform will not work because it only happens between two image view use matrix,So there will be a strange flick in shared element transition end. I've tried extend image view but with no luck. Can you help me with this?:)
I have met the same problem, I want to have a animation between two activities using ActivityOptions and Transition. The shared elements are ImageView and SubsamplingScaleImageView, and the default animation is really awkward and stiff, how to solve it
You need custom transition to handle the change smoothly, including zoomed scale of SubsamplingImageView. Easiest way to do is to wait until image is loaded before starting transition (also prevents flickering), then reading off size of the target image and size of view itself to properly calculate the required scale.
I don't want to drop ton of code here, so I'll just link to gist with complete transition.
I couldn't get the code posted by @Uiasdnmb to work. The view will not load the base layer image until it has dimensions. Events are happening in the wrong order, and there is no call to onDraw after the view gets dimensions, so it never loads and the transition does not start.
This may be fixable with extra code in onSizeChanged, but I've seen what the animation looks like and it doesn't achieve the same affect as native transitions due to scale and center being animated while the view's position and size are also being animated. This means the image center moves along a curved path. The exit transition after zooming in also looks odd - parts of the image are outside the view bounds and become visible while it's shrinking and zooming out.
I've tried another approach - transitioning from one ImageView to another ImageView, then superimposing the SubsamplingScaleImageView on top of it. That works very well for enter transitions, and looks pretty good for exit transitions unless the thumbnail image is low quality. However, if the thumbnail's scale type is centerCrop the exit transition looks rubbish - an Android bug I can't find any solution for.
Did you properly postpone enter transition in onCreate() and start in when image was ready? Also if you're creating transition in code without inflating xml you need to set target manually. I haven't tested if it works in fragment transitions either.
I actually did experiment with superimposing ImageView s, but for my use case I needed to transition from centerCrop into fitCenter and that didn't work well at all.
Once I even tried using exif interface (in onCreate()) and injecting image size into my transition, and it did work without postponing but caused flickering since image was not loaded when transition started.
Initially I got it mostly working without the postpone - enough to see it animate - but the view initialised incorrectly (and after the start of the transition) because it loaded tiles appropriate for a thumbnail sized view. Once I added the postpone call, it stopped working completely. There was no call to onDraw after the view was given dimensions, so no trigger for it to initialise. This can be fixed but as I said above the resulting animation isn't quite right.
I found the enter transition from centerCrop -> fitCenter worked well with a superimposed ImageView, but the exit transition was buggy.
There are other options but they're all very complicated.
Hi, how to swap images at run time by using this library? Please help me. Thanks in advance.
Hi,is there someone solved this problem?