androidx.wear.compose.foundation.lazy

Interfaces

ScalingLazyListItemInfo

Contains useful information about an individual item in a ScalingLazyColumn.

ScalingLazyListItemScope

Receiver scope being used by the item content parameter of ScalingLazyColumn.

ScalingLazyListLayoutInfo

Contains useful information about the currently displayed layout state of ScalingLazyColumn.

ScalingLazyListScope

Receiver scope which is used by ScalingLazyColumn.

ScalingParams

Parameters to control the scaling of the contents of a ScalingLazyColumn.

TransformingLazyColumnItemScope

Receiver scope being used by the item content parameter of TransformingLazyColumn.

TransformingLazyColumnLayoutInfo

Holds the layout information for a TransformingLazyColumn.

TransformingLazyColumnScope

Receiver scope which is used by TransformingLazyColumn.

TransformingLazyColumnVisibleItemInfo

Represents an item that is visible in the TransformingLazyColumn component.

Classes

AutoCenteringParams

Parameters to determine which list item and offset to calculate auto-centering spacing for.

ScalingLazyListAnchorType
ScalingLazyListState

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

TransformingLazyColumnItemScrollProgress

Scroll progress of an item in a TransformingLazyColumn before any modifications to the item's height are applied (using TransformingLazyColumnItemScope.transformedHeight modifier).

TransformingLazyColumnState

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

Objects

ScalingLazyColumnDefaults

Contains the default values used by ScalingLazyColumn

Annotations

ScalingLazyScopeMarker

DSL marker used to distinguish between lazy layout scope and the item scope.

TransformingLazyColumnScopeMarker

DSL marker used to distinguish between lazy layout scope and the item scope.

Top-level functions summary

Unit
@Composable
ScalingLazyColumn(
    modifier: Modifier,
    state: ScalingLazyListState,
    contentPadding: PaddingValues,
    reverseLayout: Boolean,
    verticalArrangement: Arrangement.Vertical,
    horizontalAlignment: Alignment.Horizontal,
    flingBehavior: FlingBehavior,
    userScrollEnabled: Boolean,
    scalingParams: ScalingParams,
    anchorType: ScalingLazyListAnchorType,
    autoCentering: AutoCenteringParams?,
    rotaryScrollableBehavior: RotaryScrollableBehavior?,
    content: ScalingLazyListScope.() -> Unit
)

A scrolling scaling/fisheye list component that forms a key part of the Wear Material Design language.

Unit
@Composable
TransformingLazyColumn(
    modifier: Modifier,
    state: TransformingLazyColumnState,
    verticalArrangement: Arrangement.Vertical,
    horizontalAlignment: Alignment.Horizontal,
    flingBehavior: FlingBehavior,
    userScrollEnabled: Boolean,
    rotaryScrollableBehavior: RotaryScrollableBehavior?,
    content: TransformingLazyColumnScope.() -> Unit
)

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

Unit
@Composable
TransformingLazyColumn(
    contentPadding: PaddingValues,
    modifier: Modifier,
    state: TransformingLazyColumnState,
    verticalArrangement: Arrangement.Vertical,
    horizontalAlignment: Alignment.Horizontal,
    flingBehavior: FlingBehavior,
    userScrollEnabled: Boolean,
    rotaryScrollableBehavior: RotaryScrollableBehavior?,
    content: TransformingLazyColumnScope.() -> Unit
)

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

ScalingLazyListState
@Composable
rememberScalingLazyListState(
    initialCenterItemIndex: Int,
    initialCenterItemScrollOffset: Int
)

Creates a ScalingLazyListState that is remembered across compositions.

TransformingLazyColumnState

Creates a TransformingLazyColumnState that is remembered across compositions.

Extension functions summary

inline Unit
<T : Any?> ScalingLazyListScope.items(
    items: Array<T>,
    noinline key: ((item) -> Any)?,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit
)

Adds an array of items.

inline Unit
<T : Any?> ScalingLazyListScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)?,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit
)

Adds a list of items.

inline Unit
<T : Any?> TransformingLazyColumnScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)?,
    noinline contentType: (item) -> Any,
    crossinline itemContent: @Composable TransformingLazyColumnItemScope.(item) -> Unit
)

Adds a list of items.

inline Unit
<T : Any?> ScalingLazyListScope.itemsIndexed(
    items: Array<T>,
    noinline key: ((index: Int, item) -> Any)?,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit
)

Adds an array of items where the content of an item is aware of its index.

inline Unit
<T : Any?> ScalingLazyListScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)?,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit
)

Adds a list of items where the content of an item is aware of its index.

inline Unit
<T : Any?> TransformingLazyColumnScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)?,
    crossinline contentType: (index: Int, item) -> Any,
    crossinline itemContent: @Composable TransformingLazyColumnItemScope.(index: Int, item) -> Unit
)

Adds a list of items where the content of an item is aware of its index.

Top-level functions

@Composable
fun ScalingLazyColumn(
    modifier: Modifier = Modifier,
    state: ScalingLazyListState = rememberScalingLazyListState(),
    contentPadding: PaddingValues = PaddingValues(horizontal = 10.dp),
    reverseLayout: Boolean = false,
    verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy( space = 4.dp, alignment = if (!reverseLayout) Alignment.Top else Alignment.Bottom ),
    horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
    flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
    userScrollEnabled: Boolean = true,
    scalingParams: ScalingParams = ScalingLazyColumnDefaults.scalingParams(),
    anchorType: ScalingLazyListAnchorType = ScalingLazyListAnchorType.ItemCenter,
    autoCentering: AutoCenteringParams? = AutoCenteringParams(),
    rotaryScrollableBehavior: RotaryScrollableBehavior? = RotaryScrollableDefaults.behavior(state),
    content: ScalingLazyListScope.() -> Unit
): Unit

A scrolling scaling/fisheye list component that forms a key part of the Wear Material Design language. Provides scaling and transparency effects to the content items.

ScalingLazyColumn is designed to be able to handle potentially large numbers of content items. Content items are only materialized and composed when needed.

If scaling/fisheye functionality is not required then a LazyColumn should be considered instead to avoid any overhead of measuring and calculating scaling and transparency effects for the content items.

This overload supports rotary input. Rotary input allows users to scroll the content of the ScalingLazyColumn - by using a crown or a rotating bezel on their Wear OS device. It can be modified with rotaryScrollableBehavior param. If scroll with fling is required use RotaryScrollableDefaults.behavior. If snapping is required use RotaryScrollableDefaults.snapBehavior. Note that rotary scroll and touch scroll should be aligned. If rotaryScrollableBehavior is set for snap (using RotaryScrollableDefaults.snapBehavior), flingBehavior should be set for snap as well (using ScalingLazyColumnDefaults.snapFlingBehavior). This composable uses rememberActiveFocusRequester as FocusRequester for rotary support. It requires that this ScalingLazyColumn should be wrapped by HierarchicalFocusCoordinator. By default HierarchicalFocusCoordinator is already implemented in BasicSwipeToDismissBox, which is a part of material Scaffold - meaning that rotary will be able to request a focus without any additional changes.

Example of a ScalingLazyColumn with default parameters:

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.material.Chip
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.ListHeader
import androidx.wear.compose.material.Text

ScalingLazyColumn(modifier = Modifier.fillMaxWidth()) {
    item { ListHeader { Text(text = "List Header") } }
    items(20) {
        Chip(
            onClick = {},
            label = { Text("List item $it") },
            colors = ChipDefaults.secondaryChipColors()
        )
    }
}

Example of a ScalingLazyColumn using ScalingLazyListAnchorType.ItemStart anchoring, in this configuration the edge of list items is aligned to the center of the screen. Also this example shows scrolling to a clicked list item with ScalingLazyListState.animateScrollToItem:

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.lazy.AutoCenteringParams
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.foundation.lazy.ScalingLazyListAnchorType
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
import androidx.wear.compose.material.Chip
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.ListHeader
import androidx.wear.compose.material.Text

val coroutineScope = rememberCoroutineScope()
val itemSpacing = 6.dp
// Line up the gap between the items on the center-line
val scrollOffset = with(LocalDensity.current) { -(itemSpacing / 2).roundToPx() }
val state =
    rememberScalingLazyListState(
        initialCenterItemIndex = 1,
        initialCenterItemScrollOffset = scrollOffset
    )

ScalingLazyColumn(
    modifier = Modifier.fillMaxWidth(),
    anchorType = ScalingLazyListAnchorType.ItemStart,
    verticalArrangement = Arrangement.spacedBy(itemSpacing),
    state = state,
    autoCentering = AutoCenteringParams(itemOffset = scrollOffset)
) {
    item { ListHeader { Text(text = "List Header") } }
    items(20) {
        Chip(
            onClick = {
                coroutineScope.launch {
                    // Add +1 to allow for the ListHeader
                    state.animateScrollToItem(it + 1, scrollOffset)
                }
            },
            label = { Text("List item $it") },
            colors = ChipDefaults.secondaryChipColors()
        )
    }
}

Example of a ScalingLazyColumn with snap of items to the viewport center:

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.Modifier
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.foundation.lazy.ScalingLazyColumnDefaults
import androidx.wear.compose.foundation.lazy.rememberScalingLazyListState
import androidx.wear.compose.foundation.rotary.RotaryScrollableDefaults
import androidx.wear.compose.material.Chip
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.ListHeader
import androidx.wear.compose.material.Text

val state = rememberScalingLazyListState()
ScalingLazyColumn(
    rotaryScrollableBehavior = RotaryScrollableDefaults.snapBehavior(scrollableState = state),
    flingBehavior = ScalingLazyColumnDefaults.snapFlingBehavior(state = state),
    modifier = Modifier.fillMaxWidth(),
    state = state,
) {
    item { ListHeader { Text(text = "List Header") } }
    items(20) {
        Chip(
            onClick = {},
            label = { Text("List item $it") },
            colors = ChipDefaults.secondaryChipColors()
        )
    }
}

Example of a ScalingLazyColumn where autoCentering has been disabled and explicit contentPadding provided to ensure there is space above the first and below the last list item to allow them to be scrolled into view on circular screens:

import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.lazy.ScalingLazyColumn
import androidx.wear.compose.material.Chip
import androidx.wear.compose.material.ChipDefaults
import androidx.wear.compose.material.ListHeader
import androidx.wear.compose.material.Text

ScalingLazyColumn(
    modifier = Modifier.fillMaxWidth(),
    contentPadding = PaddingValues(top = 20.dp, bottom = 20.dp),
    autoCentering = null
) {
    item { ListHeader { Text(text = "List Header") } }
    items(20) {
        Chip(
            onClick = {},
            label = { Text("List item $it") },
            colors = ChipDefaults.secondaryChipColors()
        )
    }
}

For more information, see the Lists guide.

Parameters
modifier: Modifier = Modifier

The modifier to be applied to the component

state: ScalingLazyListState = rememberScalingLazyListState()

The state of the component

contentPadding: PaddingValues = PaddingValues(horizontal = 10.dp)

The padding to apply around the contents

reverseLayout: Boolean = false

reverse the direction of scrolling and layout, when true items will be composed from the bottom to the top

verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy( space = 4.dp, alignment = if (!reverseLayout) Alignment.Top else Alignment.Bottom )

The vertical arrangement of the layout's children. This allows us to add spacing between items and specify the arrangement of the items when we have not enough of them to fill the whole minimum size

horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally

the horizontal alignment applied to the items

flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior()

Logic describing fling behavior for touch scroll. If snapping is required use ScalingLazyColumnDefaults.snapFlingBehavior. Note that when configuring fling or snap behavior, this flingBehavior parameter and the rotaryScrollableBehavior parameter that controls rotary scroll are expected to produce similar list scrolling. For example, if rotaryScrollableBehavior is set for snap (using RotaryScrollableDefaults.snapBehavior), flingBehavior should be set for snap as well (using ScalingLazyColumnDefaults.snapFlingBehavior)

userScrollEnabled: Boolean = true

whether the scrolling via the user gestures or accessibility actions is allowed. You can still scroll programmatically using the state even when it is disabled.

scalingParams: ScalingParams = ScalingLazyColumnDefaults.scalingParams()

The parameters to configure the scaling and transparency effects for the component

anchorType: ScalingLazyListAnchorType = ScalingLazyListAnchorType.ItemCenter

How to anchor list items to the center-line of the viewport

autoCentering: AutoCenteringParams? = AutoCenteringParams()

AutoCenteringParams parameter to control whether space/padding should be automatically added to make sure that list items can be scrolled into the center of the viewport (based on their anchorType). If non-null then space will be added before the first list item, if needed, to ensure that items with indexes greater than or equal to the itemIndex (offset by itemOffset pixels) will be able to be scrolled to the center of the viewport. Similarly space will be added at the end of the list to ensure that items can be scrolled up to the center. If null no automatic space will be added and instead the developer can use contentPadding to manually arrange the items.

rotaryScrollableBehavior: RotaryScrollableBehavior? = RotaryScrollableDefaults.behavior(state)

Parameter for changing rotary scrollable behavior. Supports scroll RotaryScrollableDefaults.behavior and snap RotaryScrollableDefaults.snapBehavior. Note that when configuring fling or snap behavior, this rotaryBehavior parameter and the flingBehavior parameter that controls touch scroll are expected to produce similar list scrolling. For example, if rotaryScrollableBehavior is set for snap (using RotaryScrollableDefaults.snapBehavior), flingBehavior should be set for snap as well (using ScalingLazyColumnDefaults.snapFlingBehavior). Can be null if rotary support is not required or when it should be handled externally - with a separate Modifier.rotaryScrollable modifier.

content: ScalingLazyListScope.() -> Unit

The content of the ScalingLazyColumn

TransformingLazyColumn

@Composable
fun TransformingLazyColumn(
    modifier: Modifier = Modifier,
    state: TransformingLazyColumnState = rememberTransformingLazyColumnState(),
    verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(space = 4.dp, alignment = Alignment.Top),
    horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
    flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
    userScrollEnabled: Boolean = true,
    rotaryScrollableBehavior: RotaryScrollableBehavior? = RotaryScrollableDefaults.behavior(state),
    content: TransformingLazyColumnScope.() -> Unit
): Unit

The vertically scrolling list that only composes and lays out the currently visible items. This is a wear specific version of LazyColumn that adds support for scaling and morphing animations.

import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.lazy.TransformingLazyColumn
import androidx.wear.compose.material.Text

val alphabet = ('A'..'Z').map { it.toString() }

fun rainbowColor(progress: Float): Color {
    val hue = progress * 360f
    val saturation = 1f
    val value = 1f

    return Color(android.graphics.Color.HSVToColor(floatArrayOf(hue, saturation, value)))
}

TransformingLazyColumn {
    items(count = alphabet.size) { index ->
        Text(
            alphabet[index],
            modifier =
                Modifier.transformedHeight { originalHeight, scrollProgression ->
                        if (scrollProgression.topOffsetFraction < 0f)
                            (originalHeight * scrollProgression.bottomOffsetFraction /
                                    (scrollProgression.bottomOffsetFraction -
                                        scrollProgression.topOffsetFraction))
                                .roundToInt()
                        else originalHeight
                    }
                    .graphicsLayer {
                        val itemProgression = scrollProgress ?: return@graphicsLayer
                        rotationY =
                            -180f +
                                (itemProgression.topOffsetFraction +
                                    itemProgression.bottomOffsetFraction) * 180f
                        val scale =
                            (itemProgression.bottomOffsetFraction -
                                max(itemProgression.topOffsetFraction, 0f)) /
                                (itemProgression.bottomOffsetFraction -
                                    itemProgression.topOffsetFraction)
                        scaleY = scale
                        translationY = size.height * (scale - 1f) / 2f
                    }
                    .drawBehind {
                        val colorProgress =
                            scrollProgress?.let {
                                (it.topOffsetFraction + it.bottomOffsetFraction) / 2f
                            } ?: 0f
                        drawCircle(rainbowColor(colorProgress))
                    }
                    .padding(20.dp)
        )
    }
}
Parameters
modifier: Modifier = Modifier

The modifier to be applied to the layout.

state: TransformingLazyColumnState = rememberTransformingLazyColumnState()

The state object to be used to control the list and the applied layout.

verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(space = 4.dp, alignment = Alignment.Top)

The vertical arrangement of the items.

horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally

The horizontal alignment of the items.

flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior()

The fling behavior to be used for the list. This parameter and the rotaryScrollableBehavior (which controls rotary scroll) should produce similar scroll effect visually.

userScrollEnabled: Boolean = true

Whether the user should be able to scroll the list. This also affects scrolling with rotary.

rotaryScrollableBehavior: RotaryScrollableBehavior? = RotaryScrollableDefaults.behavior(state)

Parameter for changing rotary scrollable behavior. This parameter and the flingBehavior (which controls touch scroll) should produce similar scroll effect. Can be null if rotary support is not required or when it should be handled externally with a separate Modifier.rotaryScrollable modifier.

content: TransformingLazyColumnScope.() -> Unit

The content of the list.

TransformingLazyColumn

@Composable
fun TransformingLazyColumn(
    contentPadding: PaddingValues,
    modifier: Modifier = Modifier,
    state: TransformingLazyColumnState = rememberTransformingLazyColumnState(),
    verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(space = 4.dp, alignment = Alignment.Top),
    horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
    flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
    userScrollEnabled: Boolean = true,
    rotaryScrollableBehavior: RotaryScrollableBehavior? = RotaryScrollableDefaults.behavior(state),
    content: TransformingLazyColumnScope.() -> Unit
): Unit

The vertically scrolling list that only composes and lays out the currently visible items. This is a wear specific version of LazyColumn that adds support for scaling and morphing animations.

import androidx.compose.foundation.layout.padding
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.lazy.TransformingLazyColumn
import androidx.wear.compose.material.Text

val alphabet = ('A'..'Z').map { it.toString() }

fun rainbowColor(progress: Float): Color {
    val hue = progress * 360f
    val saturation = 1f
    val value = 1f

    return Color(android.graphics.Color.HSVToColor(floatArrayOf(hue, saturation, value)))
}

TransformingLazyColumn {
    items(count = alphabet.size) { index ->
        Text(
            alphabet[index],
            modifier =
                Modifier.transformedHeight { originalHeight, scrollProgression ->
                        if (scrollProgression.topOffsetFraction < 0f)
                            (originalHeight * scrollProgression.bottomOffsetFraction /
                                    (scrollProgression.bottomOffsetFraction -
                                        scrollProgression.topOffsetFraction))
                                .roundToInt()
                        else originalHeight
                    }
                    .graphicsLayer {
                        val itemProgression = scrollProgress ?: return@graphicsLayer
                        rotationY =
                            -180f +
                                (itemProgression.topOffsetFraction +
                                    itemProgression.bottomOffsetFraction) * 180f
                        val scale =
                            (itemProgression.bottomOffsetFraction -
                                max(itemProgression.topOffsetFraction, 0f)) /
                                (itemProgression.bottomOffsetFraction -
                                    itemProgression.topOffsetFraction)
                        scaleY = scale
                        translationY = size.height * (scale - 1f) / 2f
                    }
                    .drawBehind {
                        val colorProgress =
                            scrollProgress?.let {
                                (it.topOffsetFraction + it.bottomOffsetFraction) / 2f
                            } ?: 0f
                        drawCircle(rainbowColor(colorProgress))
                    }
                    .padding(20.dp)
        )
    }
}
Parameters
contentPadding: PaddingValues

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. You can use it to add a padding before the first item or after the last one. If you want to add a spacing between each item use verticalArrangement.

modifier: Modifier = Modifier

The modifier to be applied to the layout.

state: TransformingLazyColumnState = rememberTransformingLazyColumnState()

The state object to be used to control the list and the applied layout.

verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(space = 4.dp, alignment = Alignment.Top)

The vertical arrangement of the items.

horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally

The horizontal alignment of the items.

flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior()

The fling behavior to be used for the list. This parameter and the rotaryScrollableBehavior (which controls rotary scroll) should produce similar scroll effect visually.

userScrollEnabled: Boolean = true

Whether the user should be able to scroll the list. This also affects scrolling with rotary.

rotaryScrollableBehavior: RotaryScrollableBehavior? = RotaryScrollableDefaults.behavior(state)

Parameter for changing rotary scrollable behavior. This parameter and the flingBehavior (which controls touch scroll) should produce similar scroll effect. Can be null if rotary support is not required or when it should be handled externally with a separate Modifier.rotaryScrollable modifier.

content: TransformingLazyColumnScope.() -> Unit

The content of the list.

rememberScalingLazyListState

@Composable
fun rememberScalingLazyListState(
    initialCenterItemIndex: Int = 1,
    initialCenterItemScrollOffset: Int = 0
): ScalingLazyListState

Creates a ScalingLazyListState that is remembered across compositions.

Parameters
initialCenterItemIndex: Int = 1

the initial value for ScalingLazyListState.centerItemIndex, defaults to 1. This will place the 2nd list item (index == 1) in the center of the viewport and the first item (index == 0) before it.

initialCenterItemScrollOffset: Int = 0

the initial value for ScalingLazyListState.centerItemScrollOffset in pixels

rememberTransformingLazyColumnState

@Composable
fun rememberTransformingLazyColumnState(): TransformingLazyColumnState

Creates a TransformingLazyColumnState that is remembered across compositions.

Extension functions

inline fun <T : Any?> ScalingLazyListScope.items(
    items: Array<T>,
    noinline key: ((item) -> Any)? = null,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit
): Unit

Adds an array of items.

Parameters
items: Array<T>

the data array

noinline key: ((item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.

crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit

the content displayed by a single item

inline fun <T : Any?> ScalingLazyListScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)? = null,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit
): Unit

Adds a list of items.

Parameters
items: List<T>

the data list

noinline key: ((item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.

crossinline itemContent: @Composable ScalingLazyListItemScope.(item) -> Unit

the content displayed by a single item

inline fun <T : Any?> TransformingLazyColumnScope.items(
    items: List<T>,
    noinline key: ((item) -> Any)? = null,
    noinline contentType: (item) -> Any = { null },
    crossinline itemContent: @Composable TransformingLazyColumnItemScope.(item) -> Unit
): Unit

Adds a list of items.

Parameters
items: List<T>

the data list

noinline key: ((item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the TransformingLazyColumn is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the TransformingLazyColumn will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.

noinline contentType: (item) -> Any = { null }

a factory of the content types for the item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.

crossinline itemContent: @Composable TransformingLazyColumnItemScope.(item) -> Unit

the content displayed by a single item.

inline fun <T : Any?> ScalingLazyListScope.itemsIndexed(
    items: Array<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit
): Unit

Adds an array of items where the content of an item is aware of its index.

Parameters
items: Array<T>

the data array

noinline key: ((index: Int, item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.

crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit

the content displayed by a single item

inline fun <T : Any?> ScalingLazyListScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit
): Unit

Adds a list of items where the content of an item is aware of its index.

Parameters
items: List<T>

the data list

noinline key: ((index: Int, item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.

crossinline itemContent: @Composable ScalingLazyListItemScope.(index: Int, item) -> Unit

the content displayed by a single item

inline fun <T : Any?> TransformingLazyColumnScope.itemsIndexed(
    items: List<T>,
    noinline key: ((index: Int, item) -> Any)? = null,
    crossinline contentType: (index: Int, item) -> Any = { _, _ -> null },
    crossinline itemContent: @Composable TransformingLazyColumnItemScope.(index: Int, item) -> Unit
): Unit

Adds a list of items where the content of an item is aware of its index.

Parameters
items: List<T>

the data list

noinline key: ((index: Int, item) -> Any)? = null

a factory of stable and unique keys representing the item. Using the same key for multiple items in the TransformingLazyColumn is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.

crossinline contentType: (index: Int, item) -> Any = { _, _ -> null }

a factory of the content types for the item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.

crossinline itemContent: @Composable TransformingLazyColumnItemScope.(index: Int, item) -> Unit

the content displayed by a single item