定义动画xml
1.activity进入效果fade.xml
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXDelta="0"
android:toXDelta="0" />
2.activity出去效果hold.xml
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
3.在activity跳转时调用
Intent intent = new Intent(SplashActivity.this,
MainActivity.class);
SplashActivity.this.startActivity(intent);
overridePendingTransition(R.anim.fade, R.anim.hold);//这句话是关键
SplashActivity.this.finish();