When I use a "Finish()" to terminate Activity Android uses some Activity ending animation by default?

Asked

Viewed 1,523 times

2

Because I would like to put a different animation, and if I put an animation before putting the finish() executes the animation and then Finish with its animation.

1 answer

2

If you simply want to close one Activity without opening another, you can do the following:

overridePendingTransition(0, android.R.anim.slide_out_right);

The parameters that this method receives are: (int enterAnim, int exitAnim). Which are respectively the incoming animation of the Activity being opened and the output animation of the current Activity.

So, if you wanted to liven up the entrance of the second Activity, and also the exit from yours, do the following:

overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);

You should call this method right after the method call finish();, thus:

finish();
overridePendingTransition(0, android.R.anim.slide_out_right);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.