自定义Activity和组件漂亮跳转效果

转自: http://www.360doc.com/content/11/0225/23/5943550_96187287.shtml
两个Activity跳转的时候,自定义翻页效果:
[java]  view plain copy
  1. Intent intent = new Intent(FirstActivity.this, SecondActivity.class);     
  2. startActivityForResult(intent, 11);  
  3.   
  4.   
  5. //添加界面切换效果,注意只有Android的2.0(SdkVersion版本号为5)以后的版本才支持     
  6. int version = Integer.valueOf(android.os.Build.VERSION.SDK);        
  7. if(version  >= 5) {  
  8. overridePendingTransition(R.anim.zoomin, R.anim.zoomout);  //此为自定义的动画效果,下面两个为系统的动画效果  
  9.  //overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);       
  10.      //overridePendingTransition(android.R.anim.slide_in_left,android.R.anim.slide_out_right);     
  11. }  

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

1,动画进入效果:zoomin.xml
[html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>     
  2. <set xmlns:android="http://schemas.android.com/apk/res/android"    
  3.         android:interpolator="@android:anim/decelerate_interpolator">  
  4.   
  5.   
  6.         <scale android:fromXScale="2.0" android:toXScale="1.0"    
  7.                    android:fromYScale="2.0" android:toYScale="1.0"    
  8.                    android:pivotX="50%p" android:pivotY="50%p"  
  9.                  android:duration="@android:integer/config_mediumAnimTime" />     
  10.                 </set>  

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

[html]
  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>     
  2. <set xmlns:android="http://schemas.android.com/apk/res/android"  
  3. android:interpolator="@android:anim/decelerate_interpolator"    
  4.        android:zAdjustment="top">     
  5.    <scale android:fromXScale="1.0" android:toXScale=".5"  
  6.  android:fromYScale="1.0" android:toYScale=".5"    
  7.            android:pivotX="50%p" android:pivotY="50%p"    
  8.            android:duration="@android:integer/config_mediumAnimTime" />  
  9.         <alpha android:fromAlpha="1.0" android:toAlpha="0"    
  10.                    android:duration="@android:integer/config_mediumAnimTime"/>     
  11.         </set>  

3.GridView的切换效果:
public void handleMessage(Message msg) {
	super.handleMessage(msg);
	if (msg.what == SEARCH_APP) {
		fenlei();
		showPackageInfo = userPackageInfo;				
		adapter = new GridViewAdapter2(AppExplorerActivity.this,AppInfolist.get(Appnumber));		
	        text.setText(getResources().getString(R.string.show1)+(Appnumber+1)+"/"+Appnumbers+getResources().getString(R.string.show2));	
		gv.setAdapter(adapter);		
               //每次执行时都会有个动画效果			
		gv.setAnimation(AnimationUtils.loadAnimation(AppExplorerActivity.this, R.anim.push_left_in)); 
}	
4.TextView和LinearLayout等都可以像GridView那样设置动画效果。



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值