Reputation: 2231
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:
Upvotes: 7
Views: 1431
Reputation: 1088
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.
Upvotes: 2