ViewComposePreviewWithRoot

fun ViewComposePreviewWithRoot(modifier: Modifier = Modifier, options: ViewComposePreviewOptions = ViewComposePreviewOptions(), content: UiTreeBuilder.(ViewGroup) -> Unit)(source)

Renders content inside a Compose preview and supplies its Android root ViewGroup.

Session retention, recreation, disposal, and theme limitations are the same as ViewComposePreview. The root is owned by the bridge: content may use it as an interop anchor but must not remove it, retain it beyond the composition, or independently dispose its render session.

Parameters

modifier

Compose modifier applied to the hosting AndroidView

options

bridge theme and debug configuration

content

ViewCompose DSL body receiving the bridge-owned Android root

Samples

ViewComposePreviewWithRoot { root ->
    Text("Host children: ${root.childCount}")
}