Android:windowIsTranslucent透明 导致activity退出动画无效


添加全局变量

protected int activityCloseEnterAnimation;
protected int activityCloseExitAnimation;
在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();
在你的程序finish之前,需要调用如下代码

@Override
public void finish() {
   super.finish();
   overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
}
















你可能感兴趣的:(转载)