Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add an animation to the activity finish()

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);             }         }     }); 

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

like image 513
b-ryce Avatar asked Dec 02 '10 00:12

b-ryce


People also ask

What is transition animation in Android?

Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.


1 Answers

I override pending transition just after calling finish();

In my case, I have done it to avoid transitions.

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

Order is important :)

like image 77
Goofyahead Avatar answered Sep 23 '22 15:09

Goofyahead