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

TvLazyVerticalGrid

Android

Component in Tv Foundation

A lazy vertical grid layout. It composes only visible rows of the grid.

Last updated:

Installation

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

Overloads

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

Parameters

namedescription
columnsdescribes the count and the size of the grid's columns, 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 laid out in the reverse order and [TvLazyGridState.firstVisibleItemIndex] == 0 means that grid is scrolled to the bottom. Note that [reverseLayout] does not change the behavior of [verticalArrangement], e.g. with [Arrangement.Top] (top) 123### (bottom) becomes (top) 321### (bottom).
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