Android 12 Developer Preview is here! Try it out, and give us your feedback!


abstract class AbstractComposeView : ViewGroup
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ androidx.compose.ui.platform.AbstractComposeView

Base class for custom android.view.Views implemented using Jetpack Compose UI. Subclasses should implement the Content function with the appropriate content. Calls to addView and its variants and overloads will fail with IllegalStateException.

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.)


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

Base class for custom android.view.Views implemented using Jetpack Compose UI.

Public methods
abstract Unit

The Jetpack Compose UI content for this view.

open Unit
addView(child: View?)

open Unit
addView(child: View?, index: Int)

open Unit
addView(child: View?, width: Int, height: Int)

open Unit
addView(child: View?, params: LayoutParams?)

open Unit
addView(child: View?, index: Int, params: LayoutParams?)


Perform initial composition for this view.


Dispose of the underlying composition and requestLayout.

open Unit
onRtlPropertiesChanged(layoutDirection: Int)


Set the CompositionContext that should be the parent of this view's composition.


Set the strategy for managing disposal of this View's internal composition.

Protected methods
open Boolean
addViewInLayout(child: View?, index: Int, params: LayoutParams?)

open Boolean
addViewInLayout(child: View?, index: Int, params: LayoutParams?, preventRequestLayout: Boolean)

open Unit

onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)

onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Inherited extension functions
operator Boolean

Returns true if view is found in this view group.