🌈 Create new beautiful Compose Gradients with our new wesite ->
Interface

GridCells

This class describes the count and the sizes of columns in vertical grids, or rows in horizontal grids.

Source set: Common
public interface GridCells

This class describes the count and the sizes of columns in vertical grids, or rows in horizontal grids.

Functions

calculateCrossAxisCellSizes

Source set: Common
public fun Density.calculateCrossAxisCellSizes(availableSize: Int, spacing: Int): List<Int>

Calculates the number of cells and their cross axis size based on availableSize and spacing.

For example, in vertical grids, spacing is passed from the grid's Arrangement.Horizontal. The Arrangement.Horizontal will also be used to arrange items in a row if the grid is wider than the calculated sum of columns.

Note that the calculated cross axis sizes will be considered in an RTL-aware manner -- if the grid is vertical and the layout direction is RTL, the first width in the returned list will correspond to the rightmost column.

Parameters

availableSize available size on cross axis, e.g. width of LazyVerticalGrid.
spacing cross axis spacing, e.g. horizontal spacing for LazyVerticalGrid. The spacing is passed from the corresponding Arrangement param of the lazy grid.

Members

Fixed

Source set: Common
public class Fixed(private val count: Int) : GridCells

Defines a grid with fixed number of rows or columns.

For example, for the vertical LazyVerticalGrid Fixed(3) would mean that there are 3 columns 1/3 of the parent width.

Functions

calculateCrossAxisCellSizes

Source set: Common
override fun Density.calculateCrossAxisCellSizes(
            availableSize: Int,
            spacing: Int,
        ): List<Int>

hashCode

Source set: Common
override fun hashCode(): Int

equals

Source set: Common
override fun equals(other: Any?): Boolean

Adaptive

Source set: Common
public class Adaptive(private val minSize: Dp) : GridCells

Defines a grid with as many rows or columns as possible on the condition that every cell has at least minSize space and all extra space distributed evenly.

For example, for the vertical LazyVerticalGrid Adaptive(20.dp) would mean that there will be as many columns as possible and every column will be at least 20.dp and all the columns will have equal width. If the screen is 88.dp wide then there will be 4 columns 22.dp each.

Functions

calculateCrossAxisCellSizes

Source set: Common
override fun Density.calculateCrossAxisCellSizes(
            availableSize: Int,
            spacing: Int,
        ): List<Int>

hashCode

Source set: Common
override fun hashCode(): Int

equals

Source set: Common
override fun equals(other: Any?): Boolean

FixedSize

Source set: Common
public class FixedSize(private val size: Dp) : GridCells

Defines a grid with as many rows or columns as possible on the condition that every cell takes exactly size space. The remaining space will be arranged through LazyGrid arrangements on corresponding axis. If size is larger than container size, the cell will be size to match the container.

For example, for the vertical LazyGrid FixedSize(20.dp) would mean that there will be as many columns as possible and every column will be exactly 20.dp. If the screen is 88.dp wide tne there will be 4 columns 20.dp each with remaining 8.dp distributed through Arrangement.Horizontal.

Functions

calculateCrossAxisCellSizes

Source set: Common
override fun Density.calculateCrossAxisCellSizes(
            availableSize: Int,
            spacing: Int,
        ): List<Int>

hashCode

Source set: Common
override fun hashCode(): Int

equals

Source set: Common
override fun equals(other: Any?): Boolean