Build apps faster with our new App builder! Check it out →

scrollAway

Android

Modifier in Wear Material Compose

Scroll an item vertically in/out of view based on a [ScrollState]. Typically used to scroll a [TimeText] item out of view as the user starts to scroll a vertically scrollable [Column] of items upwards and bring additional items into view.

Last updated:

Installation

dependencies {
   implementation("androidx.wear.compose:compose-material:1.5.0-alpha04")
}

Overloads


fun Modifier.scrollAway(
    scrollState: ScrollState,
    offset: Dp = 0.dp,
): Modifier

Parameters

namedescription
scrollStateThe [ScrollState] to used as the basis for the scroll-away.
offsetAdjustment to the starting point for scrolling away. Positive values result in the scroll away starting later.

fun Modifier.scrollAway(
    scrollState: LazyListState,
    itemIndex: Int = 0,
    offset: Dp = 0.dp,
): Modifier

Parameters

namedescription
scrollStateThe [LazyListState] to used as the basis for the scroll-away.
itemIndexThe item for which the scroll offset will trigger scrolling away.
offsetAdjustment to the starting point for scrolling away. Positive values result in the scroll away starting later.

fun Modifier.scrollAway(
    scrollState: ScalingLazyListState,
    itemIndex: Int = 1,
    offset: Dp = 0.dp,
): Modifier

Parameters

namedescription
scrollStateThe [ScalingLazyListState] to used as the basis for the scroll-away.
itemIndexThe item for which the scroll offset will trigger scrolling away.
offsetAdjustment to the starting point for scrolling away. Positive values result in the scroll away starting later, negative values start scrolling away earlier.
@Deprecated(
    "This overload is provided for backwards compatibility with Compose for Wear OS 1.1." +
        "A newer overload is available which uses ScalingLazyListState " +
        "from wear.compose.foundation.lazy package",
    level = DeprecationLevel.WARNING
)
fun Modifier.scrollAway(
    @Suppress("DEPRECATION") scrollState: androidx.wear.compose.material.ScalingLazyListState,
    itemIndex: Int = 1,
    offset: Dp = 0.dp,
): Modifier

Parameters

namedescription
scrollStateThe [ScalingLazyListState] to used as the basis for the scroll-away.
itemIndexThe item for which the scroll offset will trigger scrolling away.
offsetAdjustment to the starting point for scrolling away. Positive values result in the scroll away starting later, negative values start scrolling away earlier.
by @alexstyl