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.
The Navigation component lets you add both property and view animations to actions. To create your own animations, check out Animation resources. Navigation also includes several default animations to get you started. To add animations to an action, do the following: In the Navigation editor, click on the action where the animation should occur.
To add the transition animations, in your NavGraph, click on an Action which you want to animate its transition. On your right, you will see a pane that has a section for adding animations:
Note: When using shared elements transitions, you should not use the Animation Framework ( enterAnim, exitAnim, and so on from the previous section). Instead, you should be using only the Transition Framework for setting your enter and exit transitions. Shared elements are supplied programmatically rather than through your navigation XML file.
Android's transition framework allows you to animate all kinds of motion in your UI by simply providing the starting layout and the ending layout.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With