We just launched Compose Examples featuring over 150+ components! Check it out →

TvLazyHorizontalGrid

Android

Component in Tv Foundation

A lazy horizontal grid layout. It composes only visible columns of the grid.

Last updated:

Installation

dependencies {
   implementation("androidx.tv:tv-foundation:1.0.0-alpha11")
}

Overloads

@Deprecated(
    "LazyHorizontalGrid will, by default, set the position of focused item while " +
        "scrolling on a Tv. BringIntoViewSpec should be used to control the position.",
    replaceWith =
        ReplaceWith(
            "LazyHorizontalGrid(" +
                "modifier = modifier, " +
                "contentPadding = contentPadding, " +
                "reverseLayout = reverseLayout, " +
                "horizontalArrangement = horizontalArrangement, " +
                "verticalArrangement = verticalArrangement, " +
                "userScrollEnabled = userScrollEnabled" +
                ") { content() }",
            imports = ["androidx.compose.foundation.lazy.grid.LazyHorizontalGrid"],
        )
)
@Composable
fun TvLazyHorizontalGrid(
    rows: TvGridCells,
    modifier: Modifier = Modifier,
    state: TvLazyGridState = rememberTvLazyGridState(),
    contentPadding: PaddingValues = PaddingValues(0.dp),
    reverseLayout: Boolean = false,
    horizontalArrangement: Arrangement.Horizontal =
        if (!reverseLayout) Arrangement.Start else Arrangement.End,
    verticalArrangement: Arrangement.Vertical = Arrangement.Top,
    userScrollEnabled: Boolean = true,
    pivotOffsets: PivotOffsets = PivotOffsets(),
    content: TvLazyGridScope.() -> Unit
)

Parameters

namedescription
rowsa class describing how cells form rows, see [TvGridCells] doc for more information
modifierthe modifier to apply to this layout
statethe state object to be used to control or observe the list's state
contentPaddingspecify a padding around the whole content
reverseLayoutreverse the direction of scrolling and layout, when true items will be composed from the end to the start and [TvLazyGridState.firstVisibleItemIndex] == 0 will mean the first item is located at the end.
verticalArrangementThe vertical arrangement of the layout's children
horizontalArrangementThe horizontal arrangement of the layout's children
pivotOffsetsoffsets of child element within the parent and starting edge of the child from the pivot defined by the parentOffset.
userScrollEnabledwhether the scrolling via the user gestures or accessibility actions is allowed. You can still scroll programmatically using the state even when it is disabled.
contentthe [TvLazyGridScope] which describes the content
by @alexstyl