Function

horizontalScroll

Modify element to allow it to scroll horizontally when its content is larger than its constraints.

HorizontalScrollSample

@Sampled
@Preview
@PreviewWrapper(RemoteComponentPreviewWrapper::class)
@Composable
fun HorizontalScrollSample() {
    val scrollState = rememberRemoteScrollState()
    RemoteRow(
        modifier =
            RemoteModifier.size(200.rdp, 100.rdp)
                .background(Color.LightGray.rc)
                .horizontalScroll(scrollState),
        verticalAlignment = RemoteAlignment.CenterVertically,
    ) {
        for (i in 1..10) {
            RemoteBox(
                modifier =
                    RemoteModifier.size(80.rdp, 80.rdp).padding(5.rdp).background(Color.Red.rc),
                contentAlignment = RemoteAlignment.Center,
            ) {
                RemoteText("Item $i".rs, color = Color.White.rc)
            }
        }
    }
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: