问题描述
当从 Ativity A
更改为 b活动
,反之亦然我想要的仅 b活动
动画,但对我来说活动A
也动画。(留下一个空白空间的左屏幕) b活动
动画运作良好,我的问题是与活动A
动画。(这不应该存在)。我已设置
When change from Ativity A
to Activity B
and viceversa I want that only Activity B
to animate, but in my case Activity A
also animates.(leaving a blank space in the left of the screen) Activity B
animation is working well, my problem is with the animation of Activity A
.(which shouldn't exists). I have set
//Activity B
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
setContentView(R.layout.mylayout);
//..........
}
仅在 b活动
。我想这活动A
从来没有动画或从屏幕上消失。
only in Activity B
. I want that Activity A
never animates or disappears from the screen.
我固定的反向动画(从 b活动
更改为活动A
)以这种方式:
I fixed the reverse animation(change from Activity B
to Activity A
) in this way:
//Activity B
@Override
public void onPause(){
super.onPause();
overridePendingTransition(0, R.anim.fadeout);
}
这工作好,所以,现在的问题只是与活动A
更改为 b活动
,我想同样的行为的活动A
(只停留,没有动画)。但如果我尝试 overridePendingTransition(R.anim.fadein,0)
在的onCreate()
,活动A
从屏幕上消失。
This works good, so, now the problem is only with the change from Activity A
to Activity B
, I would like the same behave of Activity A
(just stay, no animation).But If I try overridePendingTransition(R.anim.fadein, 0);
in onCreate()
, Activity A
disappears from the screen.
fadein.xml
fadein.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="100%p" android:toXDelta="0%p" android:duration="1000"/>
fadeout.xml
fadeout.xml
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate android:fromXDelta="0%p" android:toXDelta="100%p" android:duration="1000"/>
</set>
在第一个图像是我现在得到的,在第二图像是我想要得到的。
In the first image is what I get now, in the second image is what I want to get.
推荐答案
试试这个。
staystill.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromYDelta="0%p" android:toYDelta="0%p"
android:duration="@android:integer/config_longAnimTime"
/>
这篇关于如何动画只是一个活动,当活动的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!