I have a shared element transition between two activities that works in the following way:
Intent someintent = new Intent(this, someclass.class);
if (Build.VERSION.SDK_INT >= 21) {
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this
, new Pair<>(viewClicked.findViewById(R.id.someimage), "someimage")
, new Pair<>(viewClicked.findViewById(R.id.someicon), "someicon")
);
startActivity(someintent, options.toBundle());
}
else {
startActivity(someintent);
}
this works fine, but the transition is agonisingly slow. When the image is first clicked on it seems to stall for a second or two before the transition takes place. Is this due to the "weight" of the activity being loaded or is the delay configurable?
Did you try change duration of enterTransition
and returntransition
:
private Transition enterTransition() {
ChangeBounds bounds = new ChangeBounds();
bounds.setDuration(2000);
return bounds;
}
private Transition returnTransition() {
ChangeBounds bounds = new ChangeBounds();
bounds.setInterpolator(new DecelerateInterpolator());
bounds.setDuration(2000);
return bounds;
}
And in onCreate
:
getWindow().setSharedElementEnterTransition(enterTransition());
getWindow().setSharedElementReturnTransition(returnTransition());