Drawer does not work with FragNav
See original GitHub issueI’m using FragNav for fragments navigation (https://github.com/ncapdevi/FragNav) and when i set up MainActivity like this:
@AndroidEntryPoint
class MainActivity : AppCompatActivity(), FragNavController.TransactionListener {
private val binding by viewBinding(ActivityMainBinding::inflate)
val fragNavController = FragNavController(supportFragmentManager, R.id.fragmentContainer)
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
setContentView(binding.root)
fragNavController.apply {
transactionListener = this@MainActivity
rootFragments = listOf(HomeFragment())
fragNavLogger = object : FragNavLogger {
override fun error(message: String, throwable: Throwable) {
Timber.e(throwable, message)
}
}
defaultTransactionOptions = FragNavTransactionOptions.newBuilder().customAnimations(
R.anim.slide_left_from_right,
R.anim.slide_left_from_middle,
R.anim.slide_right_from_left,
R.anim.slide_right_from_middle
).build()
initialize(savedInstanceState = savedInstanceState)
}
}
}
the Beagle.show()
returns false. When i inspect layout - no overlay is being added. If i disable FragNav like this:
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
private val binding by viewBinding(ActivityMainBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
setTheme(R.style.AppTheme)
super.onCreate(savedInstanceState)
setContentView(binding.root)
supportFragmentManager.commit {
replace(R.id.fragmentContainer, HomeFragment())
}
}
}
It works perfectly. FragNav is pretty important to me. Is there a way to bypass this issue?
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Drawer navigation header button does not work after click
I can see the button but no respond when click on it. I tried to add button click event in MainActivity > OnCreate()...
Read more >Fragment Navigation in Android Using FragNav Library
Implement clean, explicit and powerful Fragment navigation in your Android apps using FragNav library.
Read more >FragNav: A Library for managing navigation between multiple stacks ...
It should absolutely work with the navigation drawer, as the library should be entirely independent of the UI that's controlling it. There are...
Read more >FragNav vs Duo Navigation Drawer - compare differences and ...
Compare FragNav vs Duo Navigation Drawer and see what are their differences. ... My biggest issues now are with how the IDE editor...
Read more >Android Fragments Common Queries & Common Mistakes
Fragment BottomBarNavigation and drawer. ... So when people say ViewPager is not refreshed it's nothing but old ... ncapdevi/FragNav ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Awesome 👍 And thanks for posting the code as well.
Yeah, the OverlayFragment does a couple of things: while you’re right that its View hierarchy is only used for the Drawer, it also handles some Activity Results (screenshot, screen recording) and the keyline overlay module which must work for all types, so it must be added.
I’ll close this one for now, I think this is a reasonable workaround and a more elegant solution would be the ability to whitelist some Fragment tags in FragNav which doesn’t depend on us. Thanks for bringing it up, let me know if you find anything else!
Hi,
Thanks for the bug report, this sounds interesting! I’ve never used FragNav so I’m investigating this right now (I’ve managed to reproduce the issue). Should be something simple, as apparently this addOverlayFragment() function fails to do its job, my first guess was that FragNav is replacing the Fragment in the android.R.id.content FrameLayout with something else but looks like that’s not the case. Anyway, I’ll let you know when I find something.