Currently we can show classic Android views with `...
# compose
m
Currently we can show classic Android views with
AndroidView()
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
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
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
Ooh, okay, sorry. 😓
m
It's OK. Your suggestion will be useful for view migration! So thanks for that
😊 1
a
Accidentally, @yennsarah is exactly what I was looking for. Soo much thanks. This makes it easy to use compose with the current navigation api
👍 2