Google は、黒人コミュニティに対する人種平等の促進に取り組んでいます。取り組みを見る

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.

Classes

LazyListState

A state object that can be hoisted to control and observe scrolling

Top-level functions summary

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

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

Unit
LazyColumnFor(items: List<T>, modifier: Modifier = Modifier, state: LazyListState = rememberLazyListState(), 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, state: LazyListState = rememberLazyListState(), 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
LazyRow(modifier: Modifier = Modifier, state: LazyListState = rememberLazyListState(), contentPadding: PaddingValues = PaddingValues(0.dp), verticalAlignment: Alignment.Vertical = Alignment.Top, content: LazyListScope.() -> Unit)

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

Unit
LazyRowFor(items: List<T>, modifier: Modifier = Modifier, state: LazyListState = rememberLazyListState(), 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, state: LazyListState = rememberLazyListState(), 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.

LazyListState
rememberLazyListState(initialFirstVisibleItemIndex: Int = 0, initialFirstVisibleItemScrollOffset: Int = 0, interactionState: InteractionState? = null)

Creates a LazyListState that is remembered across compositions.

Top-level functions

LazyColumn

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

The vertically scrolling list that only composes and lays out the currently visible items. The content block defines a DSL which allows you to emit items of different types. For example you can use LazyListScope.item to add a single item and LazyListScope.items to add a list of items.

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text

val itemsList = (0..5).toList()
val itemsIndexedList = listOf("A", "B", "C")

LazyColumn {
    items(itemsList) {
        Text("Item is $it")
    }

    item {
        Text("Single item")
    }

    itemsIndexed(itemsIndexedList) { index, item ->
        Text("Item at index $index is $item")
    }
}
Parameters
modifier: Modifier = Modifier the modifier to apply to this layout
state: LazyListState = rememberLazyListState() the state object to be used to control or observe the list's state
contentPadding: PaddingValues = PaddingValues(0.dp) 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
content: LazyListScope.() -> Unit a block which describes the content. Inside this block you can use methods like LazyListScope.item to add a single item or LazyListScope.items to add a list of items.

LazyColumnFor

@Composable fun <T> LazyColumnFor(
    items: List<T>,
    modifier: Modifier = Modifier,
    state: LazyListState = rememberLazyListState(),
    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.lazy.LazyColumnFor
import androidx.compose.material.Text

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
state: LazyListState = rememberLazyListState() the state object to be used to control or observe the list's state
contentPadding: PaddingValues = PaddingValues(0.dp) 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,
    state: LazyListState = rememberLazyListState(),
    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.lazy.LazyColumnForIndexed
import androidx.compose.material.Text

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
state: LazyListState = rememberLazyListState() the state object to be used to control or observe the list's state
contentPadding: PaddingValues = PaddingValues(0.dp) 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