5

While windowExitTransition is working as expected I cannot get windowEnterTransition to work:

themes.xml

 <item name="android:windowEnterTransition">@android:transition/explode</item>
 <item name="android:windowExitTransition">@android:transition/explode</item>

MainActivity.java

Intent intent = new Intent(MainActivity.this, SubjectActivity.class);
startActivity(intent, ActivityOptionsCompat.makeSceneTransitionAnimation(MainActivity.this).toBundle());

Demo

Walid Ammar
  • 4,038
  • 3
  • 25
  • 48
  • Are you sure that both activities have applied the same theme with the specified transitions from above? – sockeqwe Jan 29 '15 at 01:20
  • @sockeqwe That was the issue, I had set the theme to the whole application in the manifest file, apparently it doesn't work like this, specifying the theme explicitly to the second activity solved it. You may add your comment as answer to accept it. – Walid Ammar Jan 29 '15 at 02:52

3 Answers3

4

Be sure to apply the same theme with the specified transitions to both Activities.

Vadim Caen
  • 1,526
  • 11
  • 21
sockeqwe
  • 15,574
  • 24
  • 88
  • 144
1

for example: Activity A - > Activity B if you want to set a explode transition between these activity. you should at least specify

<item name="android:windowExitTransition">@android:transition/explode</item> in the A's theme

and specify

<item name="android:windowEnterTransition">@android:transition/explode</item> in the B's theme.

so that you can see what you want now.

HappyOrca
  • 79
  • 4
1

I know this is an old post, but have you included this in your theme?

<item name="android:windowActivityTransitions">true</item>

For example :

<resources>
<!-- extend the base theme to add styles available only with API level 21+ -->
<style name="AppTheme"parent="BaseAppTheme">
    <item name="android:windowActivityTransitions">true</item>
    <item name="android:windowEnterTransition">@android:transition/slide_right</item>
    <item name="android:windowExitTransition">@android:transition/slide_left</item>
</style>
</resources>

More details here from the Google Developers website.

Anthony
  • 11
  • 4