android: activity切换之效果
Activity是android应用的重要部分;为了提高用户的体验度,加了Activity之间切换的动画效果,现在介绍的一种切换动画:
是什么效果,大家自已动手测试一下便知道:
先看进入的动画:
page_in.xml
1
2
3
4
5
6
7
8
9
10 |
<?xml version= "1.0"
encoding= "utf-8" ?> <translate android:duration= "300" android:fromXDelta= "100%" android:interpolator= "@android:anim/accelerate_interpolator" android:toXDelta= "0"
/> </ set > |
退出动画:
page_out.xml
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 |
<?xml version= "1.0"
encoding= "utf-8" ?> <translate android:duration= "200" android:fromXDelta= "0" android:interpolator= "@android:anim/accelerate_interpolator" android:toXDelta= "10%"
/> <scale android:duration= "200" android:fromXScale= "1.0" android:fromXScale= "1.0" android:interpolator= "@android:anim/accelerate_interpolator" android:pivotX= "50%" android:pivotY= "50%" android:startOffset= "100" android:toXScale= ".95" android:toXScale= ".95"
/> <alpha android:fromAlpha= "1.0" android:toAlpha= "0.5" /> </ set > |
还有一种:
page_in.xml
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 |
<?xml version= "1.0"
encoding= "utf-8" ?> <translate android:duration= "300" android:fromXDelta= "10%p" android:interpolator= "@android:anim/accelerate_interpolator" android:toXDelta= "0"
/> <scale android:duration= "300" android:fromXScale= "1.0" android:fromXScale= "1.0" android:interpolator= "@android:anim/accelerate_interpolator" android:pivotX= "0" android:pivotY= "50%" android:startOffset= "200" android:toXScale= ".95" android:toXScale= ".95"
/> <alpha android:fromAlpha= "0.5" android:toAlpha= "1" /> </ set > |
page_out.xml
1
2
3
4
5
6
7
8
9
10 |
<?xml version= "1.0"
encoding= "utf-8" ?> <translate android:duration= "400" android:fromXDelta= "0" android:interpolator= "@android:anim/accelerate_interpolator" android:toXDelta= "100%p"
/> </ set > |
然后再调用:
overridePendingTransition(R.anim.xxx, R.anim.xxx);
ok!
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。