7

I'm making a scene transition for devices with API level 20+. It is working fine, but I want to set custom duration to make the transition. Is it possible ??

My code:

ActivityOptionsCompat options =

                ActivityOptionsCompat.makeSceneTransitionAnimation(this,
                        viewStart,
                        transitionName
                );

        ActivityCompat.startActivity(this, detailsIntent, options.toBundle());
seekingStillness
  • 4,833
  • 5
  • 38
  • 68
Logic
  • 2,230
  • 2
  • 24
  • 41
  • you can customize trasition https://github.com/codepath/android_guides/wiki/Shared-Element-Activity-Transition – saeed Mar 01 '16 at 06:05

3 Answers3

13

You can set the desired duration in the new started activity, by adding:

    ChangeBounds bounds = new ChangeBounds();
    bounds.setDuration(2000);
    getWindow().setSharedElementEnterTransition(bounds);
Victor
  • 1,818
  • 13
  • 16
0

Please read #5 of Mr saeed's link. Or you can try by java code:

Window window = getWindow();
TransitionSet set = new TransitionSet();
set.addTransition(new ChangeImageTransform());
set.addTransition(new ChangeBounds());
set.setDuration(duration);
set.addListener(yourTransitionListener)
window.setSharedElementEnterTransition(set);
Cuong Nguyen
  • 1,166
  • 1
  • 11
  • 20
0

Here's a simple one-liner in Kotlin, just put it in the onCreate() of the Activity you're starting: window.sharedElementEnterTransition.duration = 300

Michael P
  • 225
  • 3
  • 11