Let’s say I have 3 activities: A, B, and C. The order goes like A to B to C. I want to add enter and exit animations to B. When I open B from A, B should have slide up animation. When I go from B to C, B should have slide down animation. Here is my code:
In the Activity A:
startActivity(new Intent(this, B.class));
overridePendingTransition(R.anim.slide_up, R.anim.no_animation); // working, I can see B is opening with slide up animation
In the Activity B:
startActivity(new Intent(this, C.class));
overridePendingTransition(R.anim.no_animation, R.anim.slide_down); // not working, slide down is not applied to B
I also tried settings window enter and exit animations in the theme XML file of B. But it is not working.
Any solution?
2
Answers
You should pass 0 for
no_animation
As Document said,
Try with pass 0 in parameter instead of
R.anim.no_animation
. It might show Slide-Down animatation forActivity B
.We can use activities navigation using navigation component. In navigation component, we can define enter and exit animation. Please check the possibilites.