I'm trying to setEnterTransition
with explode.xml file.
i tried this
<?xml version="1.0" encoding="utf-8"?>
<transitionManager xmlns:android="http://schemas.android.com/apk/res/android">
<transition android:transition="@transition/explode" />
</transitionManager>
and this
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<explode
android:duration="500"
android:interpolator="@android:interpolator/bounce" />
</transitionSet>
but explode animation did not work, any ideas?
Firstly, create a Transition XML for explode transition named explode.xml
in res/transition
folder. As,
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
<explode
android:duration="320" />
</transitionSet>
Then, in styles.xml
in your AppTheme
set android:windowContentTransitions
as true and reference the explode
transition for Enter and Exit like below:
<item name="android:windowContentTransitions">true</item>
<item name="android:windowEnterTransition">@transition/explode</item>
<item name="android:windowExitTransition">@transition/explode</item>
Now start your activity as,
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(this);
Intent intent = new Intent(MainActivity.this, SecondActivitiy.class);
startActivity(intent, options.toBundle());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With