← Back to Foundation
HorizontalScroller
Overview
Code Examples
A container that composes all of its contents and lays it out, fitting the height of the child. If the child's width is less than the Constraints.maxWidth, the child's width is used, or the Constraints.maxWidth otherwise. If the contents don't fit the width, the drag gesture allows scrolling its content horizontally. The contents of the HorizontalScroller are clipped to the HorizontalScroller's bounds.
If you want to control scrolling position from the code, e.g smooth scroll to position, you must own memorized instance of ScrollerPosition and then use it to call scrollTo...
functions on it. Same tactic can be applied to the VerticalScroller
@param scrollerPosition state of this Scroller that holds current scroll position and provides user with useful methods like smooth scrolling @param modifier Modifier to be applied to the Scroller content layout @param isScrollable param to enabled or disable touch input scrolling, default is true
Overloads
HorizontalScroller
@Deprecated(
"Use ScrollableRow instead", replaceWith = ReplaceWith(
"ScrollableRow(modifier = modifier, children = children)",
"androidx.compose.foundation.ScrollableRow"
)
)
@Composable
fun HorizontalScroller(
scrollerPosition: ScrollerPosition = ScrollerPosition(),
modifier: Modifier = Modifier,
isScrollable: Boolean = true,
children: @Composable RowScope.() -> Unit
)
Parameters
Name | Description |
---|---|
scrollerPosition | state of this Scroller that holds current scroll position and provides user with useful methods like smooth scrolling |
modifier | Modifier to be applied to the Scroller content layout |
isScrollable | param to enabled or disable touch input scrolling, default is tru |