当启动动画出现,退出动画失效的时候请按照以下步骤进行:
1.
添加全局变量
protected int activityCloseEnterAnimation;
protected int activityCloseExitAnimation
2.
在OnCreate里面添加如下代码:
TypedArray activityStyle = getTheme().obtainStyledAttributes(new int[] {android.R.attr.windowAnimationStyle});
int windowAnimationStyleResId = activityStyle.getResourceId(0, 0);
activityStyle.recycle();
activityStyle = getTheme().obtainStyledAttributes(windowAnimationStyleResId, new int[] {android.R.attr.activityCloseEnterAnimation, android.R.attr.activityCloseExitAnimation});
activityCloseEnterAnimation = activityStyle.getResourceId(0, 0);
activityCloseExitAnimation = activityStyle.getResourceId(1, 0);
activityStyle.recycle();
3.
在你的程序finish之前,需要调用如下代码:
overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
我调用的例子如下:
@Override
public void finish() {
Log.i(TAG, “finish”);
super.finish();
overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
}