composable. I'm curious if there will be a way to show `Fragment`s in composables? Maybe it's already possible (I haven't tried yet). Maybe we can wrap fragment within a
FrameLayout
or something?
The reason why I'm asking is that we're thinking of moving our app navigation to be within composables. All our screens are
Fragment
s at the moment and ideally we would like to avoid converting each fragment to a custom view (before we can convert each of them to be composables)
y
yennsarah
06/17/2020, 8:37 AM
Copy code
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val fragmentView = inflater.inflate(R.layout.fragment_home, container, false)
(fragmentView as FrameLayout).setContent(Recomposer.current()) {
// Compose code
}
return fragmentView
}
This works for me - fragment xml is just a framelayout 🙂
👍 1
m
Mantas Varnagiris
06/17/2020, 8:40 AM
Sorry I may have been not clear enough. I want it the other way around. I want fragments to render within composables, not composables to render within fragments
So for us to slowly migrate our views - your suggestion would work. But we want to migrate our navigation and for that we want to render fragments within composables
y
yennsarah
06/17/2020, 8:43 AM
Ooh, okay, sorry. 😓
m
Mantas Varnagiris
06/17/2020, 8:44 AM
It's OK. Your suggestion will be useful for view migration! So thanks for that
😊 1
a
andylamax
06/17/2020, 8:53 AM
Accidentally, @yennsarah is exactly what I was looking for. Soo much thanks. This makes it easy to use compose with the current navigation api