Reputation: 595
I had three question
setViewContent
which accept composable
function as input parameter similar to
setContent
. So, what is a difference between setViewContent
and setContent
and its use-cases. You can able to see setViewContent
in androidx.compose
package.setContent
and setViewContent
both return CompositionContext?
. So, how and for what, we will use CompositionContent
.layout.xml
with new compose ui
in same activity or fragment. Upvotes: 6
Views: 3310
Reputation: 24044
Here are my comments and my understanding:
setContent
will make the composable passed as parameter as the root component of your activity/fragment. On the other hand, setViewContent
will add a FrameLayout
as root element of your activity/fragment which allow you to add another views on it.Composition
object, which afaik, it's used just to display the content via setContent
and clear the hierarchy that was created from the composition via dispose
.dev14
you can use AndroidView
like this:AndroidView(resId = R.layout.my_layout) { view ->
val textView = view.findViewById<TextView>(R.id.textView)
...
}
Upvotes: 2