question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NavigationAdvancedSample: Fragment animations run when switching tabs

See original GitHub issue

When setting animations on the action action_title_to_about in home.xml navigation graph as below: Screenshot 2019-04-29 at 17 17 29

We now get a nice fade-in fade-out animation when navigating from Home -> About. The issue is, when we switch tabs and return to the home tab, the fade-in animation is re-run.

nav-animations

Is this intended behaviour? Or a consequence of using a separate NavHostFragment for each tab? We’d like the animations to be run when navigating within the tab, but not when switching tabs.

I’m considering this is as an issue with the samples rather than the navigation component as it may be down to how NavigationExtensions implements the attaching/detaching of the NavHostFragments.

Any help/workarounds would be appreciated 😄

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
droidwavecommented, Jun 7, 2019
2reactions
STAR-ZEROcommented, Jun 5, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Fragment animations run when switching tabs · Issue ... - GitHub
We'd like the animations to be run when navigating within the tab, but not when switching tabs. I'm considering this is as an...
Read more >
Navigate between fragments using animations
First, you need to create animations for your enter and exit effects, which are run when navigating to a new fragment. You can...
Read more >
Separate Back Stack for each tab in BottomNavigationView ...
I am using Fragments to set the content for each tab. I know how to set up one fragment for each tab and...
Read more >
Support multiple back stacks for Bottom tab navigation
Changing tab with the bottom bar resets the state and backstack of the ... the switch tab animation is overriden by current fragment...
Read more >
Fragment Navigation in Android Using FragNav Library
Maybe you want to eagerly pre-instantiate all root Fragments to make switch between tabs quicker? This too is just one line of code....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found