ListKt
public final class ListKt
Summary
Public methods |
|
|---|---|
static final void |
@ComposableThis is a scrolling list component that only composes and lays out the currently visible items. |
Public methods
VerticalList
@Composable
public static final void VerticalList(
@NonNull Modifier modifier,
@NonNull ListState state,
@NonNull PaddingValues contentPadding,
boolean userScrollEnabled,
OverscrollEffect overscrollEffect,
boolean reverseLayout,
@NonNull Alignment.Horizontal horizontalAlignment,
@NonNull Arrangement.Vertical verticalArrangement,
@NonNull Function1<@NonNull ListScope, Unit> content
)
This is a scrolling list component that only composes and lays out the currently visible items. It is based on androidx.compose.foundation.lazy.LazyColumn, but with extra functionality and customized behavior required for Glimmer. Glimmer applications should always use VerticalList instead of LazyColumn to ensure correct behavior.
The content block defines a DSL which allows you to emit items of different types. For example you can use ListScope.item to add a single item and ListScope.items to add a list of items.
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.PaddingValues import androidx.compose.ui.unit.dp import androidx.xr.glimmer.ListItem import androidx.xr.glimmer.Text import androidx.xr.glimmer.list.VerticalList VerticalList( contentPadding = PaddingValues(16.dp), verticalArrangement = Arrangement.spacedBy(20.dp), ) { item { ListItem { Text("Header") } } items(count = 10) { index -> ListItem { Text("Item-$index") } } item { ListItem { Text("Footer") } } }
| Parameters | |
|---|---|
@NonNull Modifier modifier |
the modifier to apply to this layout. |
@NonNull ListState state |
the state object to be used to control or observe the list's state. |
@NonNull PaddingValues contentPadding |
a padding around the whole content. This will add padding for the. content after it has been clipped, which is not possible via |
boolean userScrollEnabled |
If user gestures are enabled. |
OverscrollEffect overscrollEffect |
the |
boolean reverseLayout |
reverses the direction of scrolling and layout. |
@NonNull Alignment.Horizontal horizontalAlignment |
aligns items horizontally. |
@NonNull Arrangement.Vertical verticalArrangement |
is arrangement for items. This only applies if the content is smaller than the viewport. |
@NonNull Function1<@NonNull ListScope, Unit> content |
a block which describes the content. Inside this block you can use methods like |