overridePendingTransition只显示进入动画 [英] overridePendingTransition shows enter animation only
问题描述
当用户改变了语言环境,我想重新加载活动的新的语言环境。我想创建一个动画过渡完成的活动,并再次启动它的时候。
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 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);
和我的 scale_to_center.xml
是:
<?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>
和我的 scale_from_center.xml
是:
<?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.
然而,当我改变了code仅动画应用程序的退出。它的工作。
However when I changed the code to only animate the exit of application. It worked.
finish();
overridePendingTransition(0, R.anim.scale_to_center);
感谢。
推荐答案
设置两个动画的方法 overridePendingTransition
,并呼吁结束的在您'已经叫 startActivity
:
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();
这篇关于overridePendingTransition只显示进入动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!