---
title: "ScalingLazyListState"
description: "A state object that can be hoisted to control and observe scrolling.

In most cases, this will be created via [rememberScalingLazyListState].


If the developer wants custom control over position and spacing they can switch off autoCentering
and provide contentPadding.


Note that it is not always possible for the values provided by [initialCenterItemIndex] and
[initialCenterItemScrollOffset] to be honored, e.g. If [initialCenterItemIndex] is set to a value
larger than the number of items initially in the list, or to an index that can not be placed in
the middle of the screen due to the contentPadding or autoCentering properties provided to the
[ScalingLazyColumn]. After the [ScalingLazyColumn] is initially drawn the actual values for the
[centerItemIndex] and [centerItemScrollOffset] can be read from the state."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-android'>Android</div>


```kotlin
public class ScalingLazyListState(
    private var initialCenterItemIndex: Int = 1,
    private var initialCenterItemScrollOffset: Int = 0,
) : ScrollableState
```


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

In most cases, this will be created via `rememberScalingLazyListState`.


If the developer wants custom control over position and spacing they can switch off autoCentering
and provide contentPadding.


Note that it is not always possible for the values provided by `initialCenterItemIndex` and
`initialCenterItemScrollOffset` to be honored, e.g. If `initialCenterItemIndex` is set to a value
larger than the number of items initially in the list, or to an index that can not be placed in
the middle of the screen due to the contentPadding or autoCentering properties provided to the
`ScalingLazyColumn`. After the `ScalingLazyColumn` is initially drawn the actual values for the
`centerItemIndex` and `centerItemScrollOffset` can be read from the state.

#### Parameters

| | |
| --- | --- |
| initialCenterItemIndex | 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 | the initial value for `ScalingLazyListState.centerItemScrollOffset` |



## Functions

```kotlin
public suspend fun scrollToItem(
        /*@IntRange(from = 0)*/
        index: Int,
        /*@IntRange(from = 0)*/
        scrollOffset: Int = 0,
    )
```


Instantly brings the item at `index` to the center of the viewport and positions it based on
the `Configuration.anchorType` and applies the `scrollOffset` pixels.

#### Parameters

| | |
| --- | --- |
| index | the index to which to scroll. Must be non-negative. |
| scrollOffset | the offset that the item should end up after the scroll. Note that positive offset refers to forward scroll, so in a top-to-bottom list, positive offset will scroll the item further upward (taking it partly offscreen). |



```kotlin
public suspend fun animateScrollToItem(
        /*@IntRange(from = 0)*/
        index: Int,
        /*@IntRange(from = 0)*/
        scrollOffset: Int = 0,
    )
```


Animate (smooth scroll) the given item at `index` to the center of the viewport and position
it based on the `Configuration.anchorType` and applies the `scrollOffset` pixels.

#### Parameters

| | |
| --- | --- |
| index | the index to which to scroll. Must be non-negative. |
| scrollOffset | the offset that the item should end up after the scroll (same as `scrollToItem`) - note that positive offset refers to forward scroll, so in a top-to-bottom list, positive offset will scroll the item further upward (taking it partly offscreen) |



## Companion Object

#### Properties

<div class='sourceset sourceset-android'>Android</div>


```kotlin
public val Saver: Saver<ScalingLazyListState, Any>
```


The default `Saver` implementation for `ScalingLazyListState`.





