overridePendingTransition shows enter animation only
android, android-activity, android-animation, android-layout, java
Solution
Set the two animations on the method `overridePendingTransition` and call finish after you've called `startActivity`:
Intent intent = new Intent(SettingsActivity.this, SettingsActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.scale_from_center, R.anim.scale_to_center);
finish();
Problem
When the user changes the language locale, I would like to reload the activity with the new locale. I want to create an animated transition when finishing the Activity and starting it again. The transition animation is as follows: The exit animation is to scale the activity to the center of the screen. The enter animation is to scale the activity from the center of the screen. ``` finish(); overridePendingTransition(0, R.anim.scale_to_center); Intent intent =new Intent(SettingsActivity.this, SettingsActivity.class); startActivity(intent); overridePendingTransition(R.anim.scale_from_center, 0); ``` and my `scale_to_center.xml` is: ``` <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromYScale="1.0" android:toYScale="0" android:fromXScale="1.0" android:toXScale="0" android:pivotX="50%" android:pivotY="50%" android:duration="500"/> </set> ``` and my `scale_from_center.xml` is: ``` <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:fromYScale="0" android:toYScale="1.0" android:fromXScale="0" android:toXScale="1.0" android:pivotX="50%" android:pivotY="50%" android:startOffset="500" android:duration="2000"/> </set> ``` The problem is that ONLY the enter transition appears and the exit transition do not appear. I tried to add a delay to the exit transition but it didn't work either. However when I changed the code to only animate the exit of application. It worked. ``` finish(); overridePendingTransition(0, R.anim.scale_to_center); ``` Thanks.