我是靠谱客的博主 糟糕草丛,这篇文章主要介绍Android activity跳转动画,6种activity进入动画新activity进入方式activity实现跳转动画代码,现在分享给大家,希望可以做个参考。

源码链接:https://pan.baidu.com/s/1jAKMNUuCdWVxUm2BUCzL2g

 

添加动画anim

新activity进入方式

默认是右往左进入动画

1、下往上推进入动画——100与-100互换即可——上往下推进入动画

in:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="700" android:fromYDelta="100%p" android:toYDelta="0" /> <alpha android:duration="700" android:fromAlpha="0.0" android:toAlpha="1.0" /> </set>

out:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="700" android:fromYDelta="0" android:toYDelta="-100%p" /> <alpha android:duration="700" android:fromAlpha="1.0" android:toAlpha="0.0" /> </set>

2、左往右进入动画

in:

复制代码
1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="2000" android:fromXDelta="-100%p" android:toXDelta="0" /> </set>

out:

复制代码
1
2
3
4
5
6
7
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="2000" android:fromXDelta="0" android:toXDelta="100%p" /> </set>

3、透明淡出,中间缩放进入动画

in:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
<?xml version="1.0" encoding="utf-8"?><!-- android:duration="@android:integer/config_mediumAnimTime" --> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:duration="1000" android:fillAfter="false" android:fromXScale="0.0" android:fromYScale="0.0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toXScale="1" android:toYScale="1" /> </set>

out:

复制代码
1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="utf-8"?><!-- android:duration="@android:integer/config_mediumAnimTime" --> <set xmlns:android="http://schemas.android.com/apk/res/android"> <alpha android:duration="1000" android:fromAlpha="1.0" android:toAlpha="0" /> </set>

4、透明淡出,左上角放大进入动画

in:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="utf-8"?><!-- android:duration="@android:integer/config_mediumAnimTime" --> <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"> <scale android:duration="1000" android:fromXScale="0.0" android:fromYScale="0.0" android:interpolator="@android:anim/decelerate_interpolator" android:pivotX="0" android:pivotY="0" android:repeatCount="0" android:startOffset="0" android:toXScale="1.0" android:toYScale="1.0"></scale> </set>

out:......

5、组合动画,旋转,缩放,移动

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?xml version="1.0" encoding="utf-8"?><!-- android:duration="@android:integer/config_mediumAnimTime" --> <set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"> <scale android:duration="2000" android:fromXScale="0.0" android:fromYScale="0.0" android:interpolator="@android:anim/decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.0" android:toYScale="1.0"></scale> <translate android:duration="2000" android:fromXDelta="120" android:fromYDelta="30" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:toXDelta="30" android:toYDelta="250" /> <rotate android:duration="2000" android:fromDegrees="0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:toDegrees="+355" /> </set>

6、左上角退出,外围缩放进入动画

in:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator"> <alpha android:duration="1000" android:fromAlpha="0" android:toAlpha="1.0" /> <scale android:duration="1000" android:fromXScale="2.0" android:fromYScale="2.0" android:pivotX="50%p" android:pivotY="50%p" android:toXScale="1.0" android:toYScale="1.0" /> </set>

out:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/decelerate_interpolator" android:zAdjustment="top"> <scale android:duration="2000" android:fromXScale="1.0" android:fromYScale="1.0" android:pivotX="0" android:pivotY="0" android:toXScale="0" android:toYScale="0" /> <alpha android:duration="2000" android:fromAlpha="1.0" android:toAlpha="0" /> </set>

 

activity实现跳转动画代码

 

复制代码
1
private Context mContext;
复制代码
1
mContext = MainActivity.this;
复制代码
1
 
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
startView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, MyTwoActivity.class); mContext.startActivity(intent); ((Activity)mContext).overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit); } });

 

最后

以上就是糟糕草丛最近收集整理的关于Android activity跳转动画,6种activity进入动画新activity进入方式activity实现跳转动画代码的全部内容,更多相关Android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(76)

评论列表共有 0 条评论

立即
投稿
返回
顶部