androidandroid-5.0-lollipopandroid-transitions

Android ActivityOptions.makeSceneTransitionAnimation doesn't seem to exist


Android L introduced a new animations feature: animating between similar Views in different activities. It's documented here.

I've tried to use ActivityOptions.makeSceneTransitionAnimation, but it doesn't seem to be visible in the SDK (or in the jar at all), so I tried using reflection, and it returns a null value.

Has anyone else got it working?


Solution

  • Okay, I got it working.

    It seems like setting the value in styles.xml is completely ignored for now.

    You'll need to do this in each Activity's onCreate till that's fixed

    getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
    Transition transition = // load transition here.
    getWindow().setSharedElementEnterTransition(transition);
    getWindow().setSharedElementExitTransition(transition);
    

    As per the same bug ViewAnimationUtils has, you'll see errors in Android Studio, it'll compile and run fine though.