5

I have an activity I animate to with a transition animation, like this:

ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, view, transitionStr);
ActivityCompat.startActivity(activity, intent, options.toBundle());

However, when I go back, I don't want the animation to run in inverse. Is that possible? I'm using AppCompatActivity from appcompat-v7:23.1.1.

Michael Eilers Smith
  • 8,466
  • 20
  • 71
  • 106

3 Answers3

5

If you never want to have that transition back to the parent activity, use

finish();

You can wrap it around a condition if you sometimes want to the transition on the way back to the parent activity. An example use case would be to disable the transition when an interstitial ad was displayed:

if (interstitialAdWasDisplayed) {
  finish();
} else {
  finishAfterTransition();
}
Bruno Carrier
  • 530
  • 5
  • 8
4

A possible duplicate of Overriding Transition

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

With this piece of code, you can override the finish animation of the current activity.

Community
  • 1
  • 1
Göktay K.
  • 984
  • 9
  • 12
0

According to the answers to this question you can't run an animation in inverse. Instead I would create another transition which is basically the inverse of the transition you use when you start the activity and add it to the Activity like this (R.anim.inverseTransition is the Transition you created):

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

(see this answer for more information)

Community
  • 1
  • 1
l7r7
  • 1,134
  • 1
  • 7
  • 23