Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 358
MohammadAG Avatar asked Jul 01 '14 19:07

MohammadAG


2 Answers

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.

like image 145
MohammadAG Avatar answered Nov 17 '22 02:11

MohammadAG


We can got it working with theme config for v21. Put these items into res/values-v21/styles.xml

 <item name="android:windowContentTransitions">true</item>
 <item name="android:windowAllowEnterTransitionOverlap">true</item>
 <item name="android:windowAllowReturnTransitionOverlap">true</item>
like image 5
Vova K. Avatar answered Nov 17 '22 01:11

Vova K.