Android的活动过渡动画 [英] Android Activity Transition Animation
问题描述
我所试图实现的是:启动新的活动与过渡动画的退出活动的仅
What I am trying to achieve is : start a new activity with a transition animation for the exiting activity only.
我想向上滑动当前活动,其中新活动将落后于当前。
I would like to slide up the current activity, where the new activity will be behind the current one.
下面是向上滑动动画: R.layout.slide_up
Here is the slide up animation : R.layout.slide_up
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:fromYDelta="0%"
android:toYDelta="100%" />
</set>
下面是我如何申请活动的动画过渡:
Here is how I am applying the activity animation transition :
overridePendingTransition ( 0 , R.anim.slide_up );
我是用0到入活动,因为我不希望任何动画的新的活动,它不工作(不执行动画)。如果我使用的动画进入活动也一样,它的作品(包括动画执行),像这样的:
I am using 0 for the entering activity since I do not want any animation for the new activity, and it is not working (the animation is not performed). If I use an animation for entering activity too, it works (both animations are performed), like such :
overridePendingTransition ( R.anim.slide_out , R.anim.slide_up );
其中 R.anim.slide_out
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:fromYDelta="100%"
android:toYDelta="0%" />
</set>
任何想法?
我的工作在Android 4.1.2和Android 4.0.4
I am working on Android 4.1.2 and Android 4.0.4
推荐答案
改变你退出的动画,使得它呈现在进入活动之上。
Alter your exit animation so that it renders over top of the entering activity.
R.anim.slide_up
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:zAdjustment="top">
<translate
android:duration="1000"
android:fromYDelta="0%"
android:toYDelta="100%" />
</set>
然后,你可以做你最初做的,设置动画。
Then you can do what you were originally doing to set the animation.
overridePendingTransition ( 0 , R.anim.slide_up );
这篇关于Android的活动过渡动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!