设置setInAnimation和setOutAnimation同时开始活动 [英] set setInAnimation and setOutAnimation while starting activity
问题描述
我有以下的情况
TabActivity>group activiyt>(A->B->C)
下面A,B和C的活动。而我加载像这样
Here A,B and C are activities. And me loading like this
setContentView(this,getLocalActivityManager().startActivity("zero",intent.addFlags(Intent.FLG_ACTIVITY_CLEAR_TOP)) .getDecorView());
我需要的是设置动画(幻灯片左/右),当我一个活动换到另一个?结果
目前我使用了下面的动画,之后的setContentView
来新视图
public static Animation inFromRightAnimation() {
Animation inFromRight = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, +1.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f);
inFromRight.setDuration(ANIMATIION_DURATION);
inFromRight.setInterpolator(new AccelerateInterpolator());
return inFromRight;
}
但它只是做动画的新观点。结果
我需要像在从右结果,同时新举措离开当前的举动
有什么办法来设置 setInAnimation
和 setOutAnimation
在startActivity状观的鳍状肢?
谢谢
but it only do animation to new view.
I need like current move left at the same time new move from right
Is there any way to set setInAnimation
and setOutAnimation
in startActivity like view flipper?
Thank you
推荐答案
您可以做活动之间的过渡动画。这里是使(LaunchActivity)屏幕,并在游戏中的主菜单画面之间飞溅5秒钟后自定义动画过渡的例子:
You can do a transition animation between activities. Here is an example to make a custom animated transition after 5 seconds between splash (LaunchActivity) screen and the main menu screen in the game:
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
/* Create an intent that will start the main activity. */
Intent mainIntent = new Intent(LaunchActivity.this,
MainMenuActivity.class);
LaunchActivity.this.startActivity(mainIntent);
/* Finish splash activity so user cant go back to it. */
LaunchActivity.this.finish();
/* Apply our splash exit (fade out) and main
entry (fade in) animation transitions. */
overridePendingTransition(R.anim.mainfadein,R.anim.splashfadeout);
}
}, 5000);
下面的动画在XML文件中定义的,但你可以在code创建它们,以及你已经这样做了。
Here the animations are defined in xml files, but you can create them in code as well as you are already doing it.
您翻译应该被保存在资源动画文件夹中的XML文件,可能是这样的:
Your translate xml file which should be saved in anim folder in res, could look like this:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="1000" />
</set>
有移动物体从屏幕的右边100%的宽度向左...
It moves an object from right 100% width of the screen to the left...
这篇关于设置setInAnimation和setOutAnimation同时开始活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!