标签:
了解Android程序设计的人应该知道,在Android 2.0之后有了overridePendingTransition(),其中里面两个参数,一个是前一个activity的退出,另一个activity的进入。
如下代码:
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.SplashScreen); new Handler().postDelayed(new Runnable() { @Override public void run() { Intent mainIntent = new Intent(SplashScreen.this, AndroidNews.class); SplashScreen.this.startActivity(mainIntent); SplashScreen.this.finish(); overridePendingTransition(R.anim.zoomin,R.anim.zoomout); } }, 3000); }
首先要在res文件夹下建立anim文件夹,然后把动画效果xml文件放到里面去
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:duration="@android:integer/config_mediumAnimTime" 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>
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:duration="@android:integer/config_mediumAnimTime" Android:fromXScale="1.0" Android:fromYScale="1.0" Android:pivotX="50%p" Android:pivotY="50%p" Android:toXScale=".5" Android:toYScale=".5" /> <alpha Android:duration="@android:integer/config_mediumAnimTime" Android:fromAlpha="1.0" Android:toAlpha="0" /> </set>
标签:
原文地址:http://www.cnblogs.com/liaojie970/p/5830357.html