# GridCells.Adaptive

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/lazy/grid/LazyGridDsl.kt+class:androidx.compose.foundation.lazy.grid.GridCells.Adaptive) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.2.0) Common/All
- Cmn

  ```
  class GridCells.Adaptive : GridCells
  ```

*** ** * ** ***

Defines a grid with as many rows or columns as possible on the condition that every cell has at least `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells.Adaptive#minSize()` space and all extra space distributed evenly.

For example, for the vertical `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyVerticalGrid.composable#LazyVerticalGrid(androidx.compose.foundation.lazy.grid.GridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.grid.LazyGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.foundation.layout.Arrangement.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Function1)` 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.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells.Adaptive#Adaptive(androidx.compose.ui.unit.Dp)(minSize: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp)` | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density.https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells.Adaptive#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)(availableSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, spacing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Calculates the number of cells and their cross axis size based on `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)`. | Cmn |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells.Adaptive#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells.Adaptive#hashCode()()` | Cmn |

## Public constructors

### Adaptive

Cmn Added in [1.9.0](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.9.0)

```
Adaptive(minSize: Dp)
```

## Public functions

### Density.calculateCrossAxisCellSizes

Cmn Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/lazy/grid/LazyGridDsl.kt+function:calculateCrossAxisCellSizes)

```
open fun Density.calculateCrossAxisCellSizes(availableSize: Int, spacing: Int): List<Int>
```

Calculates the number of cells and their cross axis size based on `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)` and `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)`.

For example, in vertical grids, `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/GridCells#(androidx.compose.ui.unit.Density).calculateCrossAxisCellSizes(kotlin.Int,kotlin.Int)` is passed from the grid's `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/Arrangement.Horizontal`. The `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/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: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | available size on cross axis, e.g. width of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyVerticalGrid.composable#LazyVerticalGrid(androidx.compose.foundation.lazy.grid.GridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.grid.LazyGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.foundation.layout.Arrangement.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Function1)`. |
| `spacing: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | cross axis spacing, e.g. horizontal spacing for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/grid/LazyVerticalGrid.composable#LazyVerticalGrid(androidx.compose.foundation.lazy.grid.GridCells,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.grid.LazyGridState,androidx.compose.foundation.layout.PaddingValues,kotlin.Boolean,androidx.compose.foundation.layout.Arrangement.Vertical,androidx.compose.foundation.layout.Arrangement.Horizontal,androidx.compose.foundation.gestures.FlingBehavior,kotlin.Boolean,androidx.compose.foundation.OverscrollEffect,androidx.compose.foundation.lazy.layout.LazyLayoutCacheWindow,kotlin.Function1)`. The spacing is passed from the corresponding `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/Arrangement` param of the lazy grid. |

### equals

Cmn

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

Cmn

```
open fun hashCode(): Int
```