androidx.xr.glimmer.list
Interfaces
LazyListItemInfo |
Contains useful information about an individual item in a |
ListItemScope |
Receiver scope being used by the item content parameter of |
ListLayoutInfo |
Information about the layout of the |
ListScope |
Receiver scope which is used by |
Classes
ListState |
A state object that can be hoisted to control and observe scrolling. |
Top-level functions summary
Unit |
@ComposableThis is a scrolling list component that only composes and lays out the currently visible items. |
ListState |
@ComposableCreates a |
Top-level functions
VerticalList
@Composable
fun VerticalList(
modifier: Modifier = Modifier,
state: ListState = rememberListState(),
contentPadding: PaddingValues = PaddingValues(0.dp),
userScrollEnabled: Boolean = true,
overscrollEffect: OverscrollEffect? = rememberOverscrollEffect(),
reverseLayout: Boolean = false,
horizontalAlignment: Alignment.Horizontal = Alignment.Start,
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
content: ListScope.() -> Unit
): Unit
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 | |
|---|---|
modifier: Modifier = Modifier |
the modifier to apply to this layout. |
state: ListState = rememberListState() |
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 |
userScrollEnabled: Boolean = true |
If user gestures are enabled. |
overscrollEffect: OverscrollEffect? = rememberOverscrollEffect() |
the |
reverseLayout: Boolean = false |
reverses the direction of scrolling and layout. |
horizontalAlignment: Alignment.Horizontal = Alignment.Start |
aligns items horizontally. |
verticalArrangement: Arrangement.Vertical = Arrangement.Top |
is arrangement for items. This only applies if the content is smaller than the viewport. |
content: ListScope.() -> Unit |
a block which describes the content. Inside this block you can use methods like |
rememberListState
@Composable
fun rememberListState(
initialFirstVisibleItemIndex: Int = 0,
initialFirstVisibleItemScrollOffset: Int = 0
): ListState
Creates a ListState that is remembered across compositions.
Changes to the provided initial values will not result in the state being recreated or changed in any way if it has already been created.
| Parameters | |
|---|---|
initialFirstVisibleItemIndex: Int = 0 |
the initial value for |
initialFirstVisibleItemScrollOffset: Int = 0 |
the initial value for |