rememberTransformingLazyColumnState

Functions summary

TransformingLazyColumnState
@Composable
rememberTransformingLazyColumnState(
    initialAnchorItemIndex: Int,
    initialAnchorItemScrollOffset: Int
)

Creates a TransformingLazyColumnState that is remembered across compositions.

Functions

rememberTransformingLazyColumnState

@Composable
fun rememberTransformingLazyColumnState(
    initialAnchorItemIndex: Int = -1,
    initialAnchorItemScrollOffset: Int = 0
): TransformingLazyColumnState

Creates a TransformingLazyColumnState that is remembered across compositions.

Parameters
initialAnchorItemIndex: Int = -1

The index of the item to be used as the anchor. If a non-negative index is provided, the state will attempt to center this item in the viewport. If a negative index is provided then the list will be initialized with the first item (index 0) pinned to the start of the viewport, respecting any content padding. This is the default behavior.

initialAnchorItemScrollOffset: Int = 0

The offset to be applied to the anchor item. Defaults to 0. This offset is ONLY used when a non-negative initialAnchorItemIndex is provided (i.e., when the item is being centered). It is ignored if initialAnchorItemIndex is less than 0. The offset is used when placing the item in the center of the screen; a positive value scrolls the item towards the end of the list, and a negative value scrolls it towards the start. This correlates with TransformingLazyColumnState.anchorItemScrollOffset.