# KeylineStateList

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/carousel/KeylineStateList.java)

*** ** * ** ***


```
public class KeylineStateList
```

<br />

*** ** * ** ***

An object that manages a `https://developer.android.com/reference/com/google/android/material/carousel/KeylineState` and handles shifting the focal keyline range to the left and right of a the carousel container automatically.

This class generates `https://developer.android.com/reference/com/google/android/material/carousel/KeylineState`s for each discreet step needed to move the focal range from it's default location to the left or right of the carousel container. These state "steps" can then be interpolated between depending on the scroll offset of the carousel to create a smooth shifting of the focal range along the scroll axis while preserving the look and feel of the original `https://developer.android.com/reference/com/google/android/material/carousel/KeylineState` arrangement.

This class does not need to account for layout direction. `https://developer.android.com/reference/com/google/android/material/carousel/CarouselLayoutManager` will handle reversing a KeylineState when being laid out right-to-left before constructing a KeylineStateList.

## Summary

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/carousel/KeylineState` | `https://developer.android.com/reference/com/google/android/material/carousel/KeylineStateList#getShiftedState(float,float,float)( float scrollOffset, float minScrollOffset, float maxScrollOffset )` Gets a shifted KeylineState appropriate for a scroll offset. |

## Public methods

### getShiftedState

```
public KeylineState getShiftedState(
    float scrollOffset,
    float minScrollOffset,
    float maxScrollOffset
)
```

Gets a shifted KeylineState appropriate for a scroll offset.

The first and last items in a carousel should never detach or scroll away from the edges of the carousel container. To enforce this while still allowing each item in the carousel to enter the focused range when the focused range is not, by default, at the beginning or end of the list, keylines need to shift along the scrolling axis in order to reach every item.

| Parameters |
|---|---|
| `float scrollOffset` | the scroll offset |
| `float minScrollOffset` | the minimum scroll offset. This moves the items as far right in a container as possible. |
| `float maxScrollOffset` | the maximum scroll offset. This moves the items as far left in a container as possible. |

| Returns |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/carousel/KeylineState` | a `https://developer.android.com/reference/com/google/android/material/carousel/KeylineState` that has been shifted according on the scroll offset. |