Activity之间切换的动画
2014-04-18 11:58
369 查看
void android.app.Activity.overridePendingTransition(int
enterAnim, int exitAnim)
public
Since: API
Level 5
Call immediately after one of the flavors of
to specify an explicit transition animation to perform next.
Parameters
-----------------------------------------------------------------------------------------------
在代码中,我们只需要实现如下:
Intent intent = new Intent();
intent.setClass(TestActivity.this,
MyActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.in_from_right,
R.anim.out_to_left);//这里的enterAnim和exitAnim可以自己发挥
这两个resource
file是放在res目录下的anim目录中。下面写两个简单的animation:
-------------------------------in_from_right.xml-------------------------------------------
<?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%p"
android:duration="500"
/>
</set>
------------------------------------out_to_left.xml----------------------------------------
<?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="0%p"
android:toXDelta="-100%p"
android:duration="500"
/>
</set>
enterAnim, int exitAnim)
public
void overridePendingTransition
(int enterAnim, int exitAnim)
Since: APILevel 5
Call immediately after one of the flavors of
startActivity(Intent)or
finish()
to specify an explicit transition animation to perform next.
Parameters
enterAnim | A resource ID of the animation resource to use for the incoming activity. Use 0 for no animation. |
---|---|
exitAnim | A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation. |
在代码中,我们只需要实现如下:
Intent intent = new Intent();
intent.setClass(TestActivity.this,
MyActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.in_from_right,
R.anim.out_to_left);//这里的enterAnim和exitAnim可以自己发挥
这两个resource
file是放在res目录下的anim目录中。下面写两个简单的animation:
-------------------------------in_from_right.xml-------------------------------------------
<?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%p"
android:duration="500"
/>
</set>
------------------------------------out_to_left.xml----------------------------------------
<?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="0%p"
android:toXDelta="-100%p"
android:duration="500"
/>
</set>
相关文章推荐
- Activity之间的动画切换学习笔记(一)
- 【Android进阶】Android中的动画详解系列 Activity之间切换动画 完美方案
- (转)Activity之间的切换动画
- Activity之间切换的动画
- activity 之间切换添加动画效果(二)
- Android_实现activity之间切换的动画效果(overridePendingTransition)
- Android中的动画具体解释系列【4】——Activity之间切换动画
- Activity 之间的切换动画《一》
- Activity之间切换的动画
- Activity之间的动画切换
- Activity之间跳转时的切换动画
- Android:Activity之间切换时动画无效
- activity之间切换动画不起作用
- 两个Activity之间的切换动画
- Activity之间的动画的切换
- activity之间切换动画一种简单方法
- Android中Activity页面之间动画切换之淡入淡出
- Android 两个activity之间“平推”的动画切换效果
- View动画另一些使用场景--LayoutAnimation和Activity之间的切换效果
- Android 利用Theme自定义Activity之间的切换动画