`
ypf3027
  • 浏览: 304273 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

自定义Activity漂亮跳转效果

阅读更多

两个Activity跳转的时候,自定义翻页效果:

 

Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
startActivityForResult(intent, 11);
    		
//添加界面切换效果,注意只有Android的2.0(SdkVersion版本号为5)以后的版本才支持
int version = Integer.valueOf(android.os.Build.VERSION.SDK);   
if(version  >= 5) {   
     overridePendingTransition(R.anim.zoomin, R.anim.zoomout);  //此为自定义的动画效果,下面两个为系统的动画效果
   //overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);  
     //overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);
}  

 

 

下面为两个自定义的动画效果XML文件,存放位置为:res/anim/

1,动画进入效果:zoomin.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
        android:interpolator="@android:anim/decelerate_interpolator">
    <scale android:fromXScale="2.0" android:toXScale="1.0"
           android:fromYScale="2.0" android:toYScale="1.0"
           android:pivotX="50%p" android:pivotY="50%p"
           android:duration="@android:integer/config_mediumAnimTime" />
</set>

 

2,动画退出效果:zoomout.xml

<?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:fromXScale="1.0" android:toXScale=".5"
           android:fromYScale="1.0" android:toYScale=".5"
           android:pivotX="50%p" android:pivotY="50%p"
           android:duration="@android:integer/config_mediumAnimTime" />
    <alpha android:fromAlpha="1.0" android:toAlpha="0"
           android:duration="@android:integer/config_mediumAnimTime"/>
</set> 

 

 

分享到:
评论
19 楼 kkvsyy 2011-06-15  
javastder 写道
这里有个Android动画效果专题 有图有真相:
http://www.ophonesdn.com/article/show/186
http://www.ophonesdn.com/article/show/185

好东东
18 楼 lrh_java 2011-05-25  
好像很酷,晚上回去就把这个加上试试!
17 楼 snowdream 2011-05-22  
非常不错,可以增加用户体验。
16 楼 weida_527 2011-05-20  
初级入门的,也要学一下呵呵
15 楼 ctfzh 2011-05-19  
领教了  正在学习中哈
14 楼 贫僧不吃肉 2011-02-25  
又有了新的视角,楼主辛苦。
13 楼 songfantasy 2011-02-23  
效果很快。挺好。
12 楼 newman335 2011-02-21  
谢谢,学习下
11 楼 wzerolai 2011-02-16  
以后有好的技术,希望楼主继续共享。
先谢啦。
10 楼 w11h22j33 2010-12-21  
没觉得怎么样
9 楼 sendy618 2010-12-18  
恩 ,不错
8 楼 Lee_Dewyze 2010-12-12  
领教了  正在学习中哈
7 楼 ymm8505 2010-12-02  
测试了一下  挺不错的 收藏着
6 楼 za3999 2010-11-30  
<a herf="#">aaa</a>
5 楼 deeplyloving 2010-11-29  
sdk2.2 加两个效果 都不生效? 是模拟器反映速度慢看不清吗?
4 楼 javastder 2010-11-25  
这里有个Android动画效果专题 有图有真相:
http://www.ophonesdn.com/article/show/186
http://www.ophonesdn.com/article/show/185
3 楼 ypf3027 2010-11-17  
huangbq 写道
这个可以增加用户体验,可以加到自己的小项目中,多谢楼主分享!楼主能贴个效果图出来就好了!


翻页效果是个短暂的过程,时间太短不好截图,所以就没有贴图,见谅!
2 楼 huangbq 2010-11-17  
这个可以增加用户体验,可以加到自己的小项目中,多谢楼主分享!楼主能贴个效果图出来就好了!
1 楼 liushihua71632 2010-11-17  
LZ,辛苦了

相关推荐

Global site tag (gtag.js) - Google Analytics