I found the problem with SimpleDraweeView of fresco at the beginning. However the problem still exists after I replace with android ImageView. So I can't be sure whether the problem is due to Android or just fresco.
What the problem is
However in my private project, and also in the sample project.
https://github.com/JackFan-Z/ActivitySharedElementTransition
The ImageView starts with scaleType "fitCenter", which is wrong.
I tried to postpone shared element transition and set different scaleType of shared element in the callbacks of SharedElementCallback. But none of them really works. Could anyone help figure out what goes wrong, or where to debug?
The screenshots of the issue
The screenshot of the first Activity:
The screenshot of transition:
The transitionName has to be unique on the screen to any other element transitions you have. Otherwise you’ll just confuse the framework and may get some weird results. in the view hierarchy. That means that ActivityA and ActivityB ImageView can have different transitionName.
This type of animation is used when we have to open an item from a ListView or RecyclerView. Shared Element Transition in Android determines how shared element views are animated from activity to activity or fragment to fragment.
Multiple Shared Elements Sometimes, you might want to animate multiple elements from the source view hierarchy. This can be achieved by using distinct transition names in the source and target layout xml files. Note: By default android.util.Pair will be imported but we want to select the android.support.v4.util.Pair class instead.
Shared element transitions between activities has a sane default transition, that works pretty much as expected. For fragments, however, you have to specify a Transition. We define a transition set in res/transition, called change_image_trans.
As you observed with ImageView
this is an Android limitation. However, I am doing some changes to Fresco scale types and it will be possible to do this once I push my changes.
In short, instead of ScaleType being an Enum (which is very inflexible), ScaleType is changed to be an interface that can be implemented to do arbitrary scaling. This change has been landed internally and will soon be pushed to GitHub.
In addition to the above, I am working on the implementation of InterpolatingScaleType that just interpolates between the two underlying scale types based on the interpolation value (0.0 - 1.0). Value of 0.0 returns the same transform as the underlying scaleType1, whereas value of 1.0 returns the same transform as the underlying scaleType2. Inbetween values are a linear combination between the two.
InterpolatingScaleType allows to smoothly interpolate between the two different scale types which is handy in animations such as when doing a view transition.
Once this is ready I will update this answer.
EDIT:
@burzumrus was kind enough to provide an implementation that you can find here on GitHub. There is also a thread on this issue on the Fresco's GitHub page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With