Google is committed to advancing racial equity for Black communities. See how.

androidx.compose.foundation.lazy

Interfaces

LazyItemScope

Receiver scope being used by the item content parameter of LazyColumn/Row.

LazyListScope

Receiver scope which is used by LazyColumn and LazyRow.

Annotations

ExperimentalLazyDsl

Top-level functions summary

Unit
LazyColumn(modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), horizontalAlignment: Alignment.Horizontal = Alignment.Start, content: LazyListScope.() -> Unit)

The DSL implementation of a vertically scrolling list that only composes and lays out the currently visible items.

Unit
LazyColumnFor(items: List<T>, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), horizontalAlignment: Alignment.Horizontal = Alignment.Start, itemContent: LazyItemScope.(T) -> Unit)

A vertically scrolling list that only composes and lays out the currently visible items.

Unit
LazyColumnForIndexed(items: List<T>, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), horizontalAlignment: Alignment.Horizontal = Alignment.Start, itemContent: LazyItemScope.(index: Int, item: T) -> Unit)

A vertically scrolling list that only composes and lays out the currently visible items.

Unit
LazyColumnItems(items: List<T>, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), horizontalGravity: Alignment.Horizontal = Alignment.Start, itemContent: (T) -> Unit)

Unit
LazyRow(modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), verticalAlignment: Alignment.Vertical = Alignment.Top, content: LazyListScope.() -> Unit)

The DSL implementation of a horizontally scrolling list that only composes and lays out the currently visible items.

Unit
LazyRowFor(items: List<T>, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), verticalAlignment: Alignment.Vertical = Alignment.Top, itemContent: LazyItemScope.(T) -> Unit)

A horizontally scrolling list that only composes and lays out the currently visible items.

Unit
LazyRowForIndexed(items: List<T>, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), verticalAlignment: Alignment.Vertical = Alignment.Top, itemContent: LazyItemScope.(index: Int, item: T) -> Unit)

A horizontally scrolling list that only composes and lays out the currently visible items.

Unit
LazyRowItems(items: List<T>, modifier: Modifier = Modifier, contentPadding: PaddingValues = PaddingValues(0.dp), verticalGravity: Alignment.Vertical = Alignment.Top, itemContent: (T) -> Unit)

Top-level functions

LazyColumn

@Composable fun LazyColumn(
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    content: LazyListScope.() -> Unit
): Unit

The DSL implementation of a vertically scrolling list that only composes and lays out the currently visible items. This API is not stable yet, please consider using LazyColumnFor instead.

Parameters
modifier: Modifier = Modifier the modifier to apply to this layout
contentPadding: PaddingValues = PaddingValues(0.dp) specify a padding around the whole content
horizontalAlignment: Alignment.Horizontal = Alignment.Start the horizontal alignment applied to the items
content: LazyListScope.() -> Unit the LazyListScope which describes the content

LazyColumnFor

@Composable fun <T> LazyColumnFor(
    items: List<T>,
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    itemContent: LazyItemScope.(T) -> Unit
): Unit

A vertically scrolling list that only composes and lays out the currently visible items.

See LazyColumnForIndexed if you need to have both item and index params in itemContent. See LazyRowFor if you are looking for a horizontally scrolling version.

import androidx.compose.foundation.Text
import androidx.compose.foundation.lazy.LazyColumnFor

val items = listOf("A", "B", "C")
LazyColumnFor(items) {
    Text("Item is $it")
}
Parameters
items: List<T> the backing list of data to display
modifier: Modifier = Modifier the modifier to apply to this layout
contentPadding: PaddingValues = PaddingValues(0.dp) convenience param to specify a padding around the whole content. This will add padding for the content after it has been clipped, which is not possible via modifier param. Note that it is not a padding applied for each item's content
horizontalAlignment: Alignment.Horizontal = Alignment.Start the horizontal alignment applied to the items
itemContent: LazyItemScope.(T) -> Unit emits the UI for an item from items list. May emit any number of components, which will be stacked vertically. Note that LazyColumnFor can start scrolling incorrectly if you emit nothing and then lazily recompose with the real content, so even if you load the content asynchronously please reserve some space for the item, for example using Spacer. Use LazyColumnForIndexed if you need to have both index and item params.

LazyColumnForIndexed

@Composable fun <T> LazyColumnForIndexed(
    items: List<T>,
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    horizontalAlignment: Alignment.Horizontal = Alignment.Start,
    itemContent: LazyItemScope.(index: Int, item: T) -> Unit
): Unit

A vertically scrolling list that only composes and lays out the currently visible items.

It is the variant of LazyColumnFor which provides both index and item as params for itemContent.

See LazyRowForIndexed if you are looking for a horizontally scrolling version.

import androidx.compose.foundation.Text
import androidx.compose.foundation.lazy.LazyColumnForIndexed

val items = listOf("A", "B", "C")
LazyColumnForIndexed(items) { index, item ->
    Text("Item at index $index is $item")
}
Parameters
items: List<T> the backing list of data to display
modifier: Modifier = Modifier the modifier to apply to this layout
contentPadding: PaddingValues = PaddingValues(0.dp) convenience param to specify a padding around the whole content. This will add padding for the content after it has been clipped, which is not possible via modifier param. Note that it is not a padding applied for each item's content
horizontalAlignment: Alignment.Horizontal = Alignment.Start the horizontal alignment applied to the items
itemContent: LazyItemScope.(index: Int, item: T) -> Unit emits the UI for an item from items list. It has two params: first one is an index in the items list, and the second one is the item at this index from items list. May emit any number of components, which will be stacked vertically. Note that LazyColumnForIndexed can start scrolling incorrectly if you emit nothing and then lazily recompose with the real content, so even if you load the content asynchronously please reserve some space for the item, for example using Spacer.

LazyColumnItems

@Composable fun <T> LazyColumnItems(
    items: List<T>,
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    horizontalGravity: Alignment.Horizontal = Alignment.Start,
    itemContent: (T) -> Unit
): Unit

Deprecated.

LazyRow

@Composable fun LazyRow(
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    verticalAlignment: Alignment.Vertical = Alignment.Top,
    content: LazyListScope.() -> Unit
): Unit

The DSL implementation of a horizontally scrolling list that only composes and lays out the currently visible items. This API is not stable yet, please consider using LazyRowFor instead.

Parameters
modifier: Modifier = Modifier the modifier to apply to this layout
contentPadding: PaddingValues = PaddingValues(0.dp) specify a padding around the whole content
verticalAlignment: Alignment.Vertical = Alignment.Top the vertical alignment applied to the items
content: LazyListScope.() -> Unit the LazyListScope which describes the content

LazyRowFor

@Composable fun <T> LazyRowFor(
    items: List<T>,
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    verticalAlignment: Alignment.Vertical = Alignment.Top,
    itemContent: LazyItemScope.(T) -> Unit
): Unit

A horizontally scrolling list that only composes and lays out the currently visible items.

See LazyRowForIndexed if you need to have both item and index params in itemContent. See LazyColumnFor if you are looking for a vertically scrolling version.

import androidx.compose.foundation.Text
import androidx.compose.foundation.lazy.LazyRowFor

val items = listOf("A", "B", "C")
LazyRowFor(items) {
    Text("Item is $it")
}
Parameters
items: List<T> the backing list of data to display
modifier: Modifier = Modifier the modifier to apply to this layout
contentPadding: PaddingValues = PaddingValues(0.dp) convenience param to specify a padding around the whole content. This will add padding for the content after it has been clipped, which is not possible via modifier param. Note that it is not a padding applied for each item's content
verticalAlignment: Alignment.Vertical = Alignment.Top the vertical alignment applied to the items
itemContent: LazyItemScope.(T) -> Unit emits the UI for an item from items list. May emit any number of components, which will be stacked horizontally. Note that LazyRowFor can start scrolling incorrectly if you emit nothing and then lazily recompose with the real content, so even if you load the content asynchronously please reserve some space for the item, for example using Spacer. Use LazyRowForIndexed if you need to have both index and item params.

LazyRowForIndexed

@Composable fun <T> LazyRowForIndexed(
    items: List<T>,
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    verticalAlignment: Alignment.Vertical = Alignment.Top,
    itemContent: LazyItemScope.(index: Int, item: T) -> Unit
): Unit

A horizontally scrolling list that only composes and lays out the currently visible items.

It is the variant of LazyRowFor which provides both index and item as params for itemContent.

See LazyColumnForIndexed if you are looking for a vertically scrolling version.

import androidx.compose.foundation.Text
import androidx.compose.foundation.lazy.LazyRowForIndexed

val items = listOf("A", "B", "C")
LazyRowForIndexed(items) { index, item ->
    Text("Item at index $index is $item")
}
Parameters
items: List<T> the backing list of data to display
modifier: Modifier = Modifier the modifier to apply to this layout
contentPadding: PaddingValues = PaddingValues(0.dp) convenience param to specify a padding around the whole content. This will add padding for the content after it has been clipped, which is not possible via modifier param. Note that it is not a padding applied for each item's content
verticalAlignment: Alignment.Vertical = Alignment.Top the vertical alignment applied to the items
itemContent: LazyItemScope.(index: Int, item: T) -> Unit emits the UI for an item from items list. It has two params: first one is an index in the items list, and the second one is the item at this index from items list. May emit any number of components, which will be stacked horizontally. Note that LazyRowForIndexed can start scrolling incorrectly if you emit nothing and then lazily recompose with the real content, so even if you load the content asynchronously please reserve some space for the item, for example using Spacer.

LazyRowItems

@Composable fun <T> LazyRowItems(
    items: List<T>,
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    verticalGravity: Alignment.Vertical = Alignment.Top,
    itemContent: (T) -> Unit
): Unit

Deprecated.