The second Android 11 Developer Preview is now available, test it out and share your feedback.

Compose

object Compose
kotlin.Any
   ↳ androidx.compose.Compose

Summary

Public methods

Composition
composeInto(container: ViewGroup, parent: CompositionReference? = null, composable: () -> Unit)

This method is the way to initiate a composition.

Composition
composeInto(container: ComponentNode, context: Context, parent: CompositionReference? = null, composable: () -> Unit)

This method is the way to initiate a composition.

Unit
disposeComposition(container: ViewGroup, parent: CompositionReference? = null)

Disposes any composition previously run with container as the root.

Unit
disposeComposition(container: ComponentNode, context: Context, parent: CompositionReference? = null)

Disposes any composition previously run with container as the root.

Public methods

composeInto

@MainThread fun composeInto(
    container: ViewGroup,
    parent: CompositionReference? = null,
    composable: () -> Unit
): Composition

Deprecated.

This method is the way to initiate a composition. The composable passed in will be executed to compose the children of the passed in container. Optionally, a parent can be provided to make the composition behave as a sub-composition of the parent. The children of container will be updated and maintained by the time this method returns.

It is important to call Composition.dispose whenever this view is no longer needed in order to release resources.

Parameters
container: ViewGroup The view whose children is being composed.
parent: CompositionReference? = null The parent composition reference, if applicable. Default is null.
composable: () -> Unit The composable function intended to compose the children of container.

composeInto

@MainThread fun composeInto(
    container: ComponentNode,
    context: Context,
    parent: CompositionReference? = null,
    composable: () -> Unit
): Composition

Deprecated.

This method is the way to initiate a composition. The composable passed in will be executed to compose the children of the passed in container. Optionally, a parent can be provided to make the composition behave as a sub-composition of the parent. The children of container will be updated and maintained by the time this method returns.

It is important to call Composition.dispose whenever this view is no longer needed in order to release resources.

Parameters
container: ComponentNode The emittable whose children is being composed.
context: Context The android Context to associate with this composition.
parent: CompositionReference? = null The parent composition reference, if applicable. Default is null.
composable: () -> Unit The composable function intended to compose the children of container.

disposeComposition

@MainThread fun disposeComposition(
    container: ViewGroup,
    parent: CompositionReference? = null
): Unit

Deprecated.

Disposes any composition previously run with container as the root. This will release any resources that have been built around the composition, including all onDispose callbacks that have been registered with CompositionLifecycleObserver objects.

It is important to call this for any composeInto call that is made, or else you may have memory leaks in your application.

Parameters
container: ViewGroup The view that was passed into composeInto as the root container of the composition
parent: CompositionReference? = null The parent composition reference, if applicable.

disposeComposition

@MainThread fun disposeComposition(
    container: ComponentNode,
    context: Context,
    parent: CompositionReference? = null
): Unit

Deprecated.

Disposes any composition previously run with container as the root. This will release any resources that have been built around the composition, including all onDispose callbacks that have been registered with CompositionLifecycleObserver objects.

It is important to call this for any composeInto call that is made, or else you may have memory leaks in your application.

Parameters
container: ComponentNode The view that was passed into composeInto as the root container of the composition
context: Context The android Context associated with the composition
parent: CompositionReference? = null The parent composition reference, if applicable.