Google 致力于为黑人社区推动种族平等。查看具体举措

ComposeView

class ComposeView : AbstractComposeView
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ androidx.compose.ui.platform.AbstractComposeView
   ↳ androidx.compose.ui.platform.ComposeView

A android.view.View that can host Jetpack Compose UI content. Use setContent to supply the content composable function for the view.

This android.view.View requires that the window it is attached to contains a ViewTreeLifecycleOwner. This androidx.lifecycle.LifecycleOwner is used to dispose of the underlying composition when the host Lifecycle is destroyed, permitting the view to be attached and detached repeatedly while preserving the composition. Call disposeComposition to dispose of the underlying composition earlier, or if the view is never initially attached to a window. (The requirement to dispose of the composition explicitly in the event that the view is never (re)attached is temporary.)

Summary

Public constructors
<init>(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0)

A android.view.View that can host Jetpack Compose UI content.

Public methods
Unit

The Jetpack Compose UI content for this view.

Unit
setContent(content: () -> Unit)

Set the Jetpack Compose UI content for this view.

Inherited functions