(一)Activity页面切换的效果Android2.0之后有了overridePendingTransition(),其中里面两个参数,一个是前一个activity的退出两一个activity的进入,Java代码1.@OverridepublicvoidonCreate(BundlesavedInstanceState){2.super.onCreate(savedInstanceState);3.4.setContentView(R.layout.SplashScreen);5.6.newHandler().postDelayed(newRunnable(){7.@Override8.publicvoidrun(){9.IntentmainIntent=newIntent(SplashScreen.this,AndroidNews.class);10.SplashScreen.this.startActivity(mainIntent);11.SplashScreen.this.finish();12.13.overridePendingTransition(R.anim.mainfadein,14.R.anim.splashfadeout);15.}16.},3000);}上面的代码只是闪屏的一部分。Java代码1.getWindow().setWindowAnimations(int);这可没有上个好但是也可以。实现淡入淡出的效果Java代码1.overridePendingTransition(Android.R.anim.fade_in,android.R.anim.fade_out);由左向右滑入的效果Java代码1.overridePendingTransition(Android.R.anim.slide_in_left,android.R.anim.slide_out_right);实现zoomin和zoomout,即类似iphone的进入和退出时的效果Java代码1.overridePendingTransition(R.anim.zoomin,R.anim.zoomout);新建zoomin.xml文件Xml代码1.?xmlversion=1.0encoding=utf-8?2.set3.xmlns:Android=:interpolator=@android:anim/decelerate_interpolatorscaleAndroid:fromXScale=2.0android:toXScale=1.05.Android:fromYScale=2.0android:toYScale=1.06.Android:pivotX=50%pandroid:pivotY=50%p7.Android:duration=@android:integer/config_mediumAnimTime//set新建zoomout.xml文件Xml代码1.?xmlversion=1.0encoding=utf-8?2.set3.xmlns:Android=:interpolator=@android:anim/decelerate_interpolator5.Android:zAdjustment=top6.scaleAndroid:fromXScale=1.0android:toXScale=.57.Android:fromYScale=1.0android:toYScale=.58.Android:pivotX=50%pandroid:pivotY=50%p9.Android:duration=@android:integer/config_mediumAnimTime/10.alphaAndroid:fromAlpha=1.0android:toAlpha=011.Android:duration=@android:integer/config_mediumAnimTime/12./set(二)android菜单动画先请注意,这里的菜单并不是按机器上的MENU出现在那种菜单,而是基于AndroidSDK提供的android.view.animation.TranslateAnimation(extendsandroid.view.animation.Animation)类实例后附加到一个Layout上使之产生的有动画出现和隐藏效果的菜单。原理:Layout(菜单)从屏幕内(挨着屏幕边沿,其实并非一定,视需要的初态和末态而定)动态的移动到屏幕外(在外面可以挨着边沿,也可以离远点,这个无所谓了),这样就可以达到动态菜单的效果了。但是由于Animation的一些奇怪特性(setFill**()函数的作用效果,这个在我使用的某几个Animation当中出现了没有想明白的效果),就暂不理会这个东西了,所以使得我们还需要用上XML属性android:visibility。当Layout(菜单)显示的时候,设置android:visibility=visible,当Layout(菜单)隐藏的时候,设置android:visibility=gone,这里android:visibility可以有3个值,visible为可见,invisible为不可见但占空间,gone为不可见且不占空间(所谓的占不占空间,这个可以自己写个XML来试试就明白了)。ClassTranslateAnimation的使用:Animation有两种定义方法,一种是用Javacode,一种是用XML,这里只介绍用code来定义(因为用XML来定义的那种我没用过。。嘿嘿。。)。多的不说,看代码。这里是TranslateAnimationMenu.java(我在里面还另加入了ScaleAnimation产生的动画,各位朋友可以照着SDK以及程序效果来理解):packagecom.TranslateAnimation.Menu;importandroid.app.Activity;importandroid.os.Bundle;importandroid.view.View;importandroid.view.View.OnClickListener;importandroid.view.animation.Animation;importandroid.view.animation.TranslateAnimation;importandroid.widget.Button;importandroid.widget.LinearLayout;publicclassTranslateAnimationMenuextendsActivity{/**Calledwhentheactivityisfirstcreated.*///TranslateAnimationshowAction,hideAction;AnimationshowAction,hideAction;LinearLayoutmenu;Buttonbutton;booleanmenuShowed;@OverridepublicvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);menu=(LinearLayout)findViewById(R.id.menu);button=(Button)findViewById(R.id.button);//这里是TranslateAnimation动画showAction=newTranslateAnimation(Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,-1.0f,Animation.RELATIVE_TO_SELF,0.0f);//这里是ScaleAnimation动画//showAction=newScaleAnimation(//1.0f,1.0f,0.0f,1.0f,Animation.RELATIVE_TO_SELF,0.0f,//Animation.RELATIVE_TO_SELF,0.0f);showAction.setDuration(500);//这里是TranslateAnimation动画hideAction=newTranslateAnimation(Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,-1.0f);//这里是ScaleAnimation动画//hideAction=newScaleAnimation(//1.0f,1.0f,1.0f,0.0f,Animation.RELATIVE_TO_SELF,0.0f,Animation.RELATIVE_TO_SELF,0.0f);hideAction.setDuration(500);menuShowed=false;menu.setVisibility(View.GONE);button.setOnClickListener(newOnClickListener(){@OverridepublicvoidonClick(Viewv){//TODOAuto-generatedmethodstubif(menuShowed){menuShowed=false;menu.startAnimation(hideAction);menu.setVisibility(View.GONE);}else{menuShowed=true;menu.startAnimation(showAction);menu.setVisibility(View.VISIBLE);}}});}}这里是main.xml:?xmlversion=1.0encoding=utf-8?RelativeLayoutxmlns:android=:orientation=verticalandroid:layout_width=fill_parentandroid:layout_height=fill_parentTextViewandroid:layout_width=fill_parentandroid:layout_height=wrap_contentandroid:text=@string/hello/LinearLayoutandroid:id=@+id/menuandroid:layout_height=100pxandroid:layout_width=fill_parentandroid:layout_alignParentTop=trueandroid:background=#ffffffTextViewandroid:layout_width=fill_parentandroid:layout_height=fill_parentandroid:text=Iamamenuandroid:gravity=center//LinearLayoutButtonandroid:id=@+id/buttonandroid:layout_width=fill