我如何添加一个动画到活动结束()结束、动画

2023-09-12 04:15:21 作者:三分坚强°七分痛

我用overridePendingTransition创建我的活动时,并工作正常,我可以看到的伟大工程的淡出,但是当我尝试和动画在活动结束它仍在做默认从右向左滑动。

I'm using overridePendingTransition for when my activity is created and that works fine I can see the fade in works great, but when I try and animate the finish on the activity it is still doing the default right to left slide.

我第一次尝试定义出动画的时候,我开始活动如下:

I first tried defining the out animation when I start the activity as follows:

Intent myIntent = new Intent(a, SkdyAlert.class);
    myIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    a.startActivity(myIntent);
    if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT) {
        AnimationHelper.overridePendingTransition(a, R.anim.fadein, R.anim.fadeout);
    }

然后,我尝试这样做,当我完成活动以及

Then I tried doing it when I finish the activity as well

okBtn.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            finish();
            if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.DONUT) {
                AnimationHelper.overridePendingTransition(activity, 0, R.anim.fadeout);
            }
        }
    });

但这两种方法将prevent的从右至左幻灯片退出动画。什么我做错了任何想法?

But neither of these approaches will prevent the "right to left" slide for the exit animation. Any ideas on what I'm doing wrong?

推荐答案

我可以覆盖挂起的过渡完成后,只调用();

i can override a pending transition just calling after finish();

在我来说,我已经做到了,以避免过渡。

in my case i have done it to avoid transitions.

finish();
Details.this.overridePendingTransition(R.anim.nothing,R.anim.nothing);

订单是很重要的:)

Order is important :)

希望它可以帮助的人!