Reputation: 610
I've been searching all around but I can't find an answer that helps solve this particular problem. My application has a custom slide-in, slide-out effect used like this:
Intent intent = new Intent(getApplicationContext(), MyActivity.class);
startActivity(intent);
overridePendingTransition(R.anim.slide_right_in, R.anim.slide_right_out);
The problem is I have a BottomNavigation included in all activities, and I don't want it to get animated, I want to exclude it.
I want to exclude the Bottom Navigation from the animation. Or, in other words, how can I only animate the content between transitions?
EDIT: I already tried doing with Shared Element, but I wanted it to work below API 21.
Upvotes: 8
Views: 2051
Reputation: 62189
It's not possible to exclude components form overridePendingTransition()
API. Instead, you have to move to Transitions API. Particularly, this is Slide
transition animation, where you exclude your bottom navigation view.
Transition slide = new Slide(Gravity.RIGHT);
slide.excludeTarget(bottomNavigationView, true);
getWindow().setEnterTransition(slide);
See detailed implementation here.
You can see support transition package which backports Transitions API functionality upto API 14. But I couldn't find Slide
transition in the classes list. Otherwise you can use TransitionEverywhere
.
Upvotes: 4