Reputation: 8021
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?
Upvotes: 20
Views: 10462
Reputation: 9473
Another way that may help some that already have the Transitions setup in their styles:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().getSharedElementEnterTransition().setDuration(2000);
getWindow().getSharedElementReturnTransition().setDuration(2000)
.setInterpolator(new DecelerateInterpolator());
}
Upvotes: 17
Reputation: 4936
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());
Upvotes: 23