0

Check this post here. I did exactly the same and it works like a charm when I open a new Activity. But the problem is, when I'm going back to the previous activity, the animation doesn't work. It works only with the default navigationBar on the Bottom. I've an actionBar with an arrow and I want to animate when the user tap on the arrow and goes to the previous activity.

I tried to add programmatically the animation, but still it doesn't work. Even the finish() function doesn't work.

override fun onBackPressed() {
    super.onBackPressed()
    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right)
}
jamesxbrown
  • 135
  • 2
  • 11
  • Hi, could you add a minimal reproducible example, the [SO answer](https://stackoverflow.com/questions/5151591/android-left-to-right-slide-animation/39943769#39943769) works for me. Albeit not perfect, some animation or the other always get's applied. – Chrisvin Jem Jul 28 '19 at 18:41

1 Answers1

0

call finish() instead of super.onBackPressed()

override fun onBackPressed() {
    finish()
    overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right)
}
plsankar
  • 437
  • 1
  • 5
  • 11