# GridTemplate

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/model/GridTemplate.java+class:androidx.car.app.model.GridTemplate) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/car/app/model/GridTemplate "View this page in Java")


```
@CarProtocol
class GridTemplate : Template
```

<br />

*** ** * ** ***

A template representing a grid of items.

#### Template Restrictions

In regards to template refreshes, as described in `https://developer.android.com/reference/kotlin/androidx/car/app/Screen#onGetTemplate()`, this template is considered a refresh of a previous one if:

- The previous template is in a loading state (see `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setLoading(boolean)`, or
- The template title has not changed, and the number of grid items and the title of each grid item have not changed.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder` A builder of `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate`. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#ITEM_IMAGE_SHAPE_CIRCLE() = 2` Represents a preference to crop all grid item images into the shape of a circle. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#ITEM_IMAGE_SHAPE_UNSET() = 1` Represents a preference to keep the images as-is without modifying their shape. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#ITEM_SIZE_LARGE() = 4` Represents a large size for all grid items within a template. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#ITEM_SIZE_MEDIUM() = 2` Represents a medium size for all grid items within a template. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#ITEM_SIZE_SMALL() = 1` Represents a small size for all grid items within a template. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#equals(java.lang.Object)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip?` | `[getActionStrip](https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getActionStrip())()` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header#getEndHeaderActions()` instead. <br /> |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/car/app/model/Action!>` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi @https://developer.android.com/reference/kotlin/androidx/car/app/annotations/RequiresCarApi(value = 7) https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getActions()()` Returns the list of additional actions. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header?` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getHeader()()` Returns the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header` to display in this template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action?` | `[getHeaderAction](https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getHeaderAction())()` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header#getStartHeaderAction()` instead. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getItemImageShape()()` Returns the item image shape. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getItemSize()()` Returns the grid item size, which applies to all grid items in the template. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList?` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getSingleList()()` Returns the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList` instance that contains the grid items to display or ` null` if not set. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarText?` | `[getTitle](https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getTitle())()` **This function is deprecated.** use `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header#getTitle()` instead. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#isLoading()()` Returns whether the template is loading. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#toString()()` |

## Constants

### ITEM_IMAGE_SHAPE_CIRCLE

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
@ExperimentalCarApi
const val ITEM_IMAGE_SHAPE_CIRCLE = 2: Int
```

Represents a preference to crop all grid item images into the shape of a circle.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setItemImageShape(int)` |   |

### ITEM_IMAGE_SHAPE_UNSET

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
@ExperimentalCarApi
const val ITEM_IMAGE_SHAPE_UNSET = 1: Int
```

Represents a preference to keep the images as-is without modifying their shape.

This is the default setting.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setItemImageShape(int)` |   |

### ITEM_SIZE_LARGE

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
@ExperimentalCarApi
const val ITEM_SIZE_LARGE = 4: Int
```

Represents a large size for all grid items within a template.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setItemSize(int)` |   |

### ITEM_SIZE_MEDIUM

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
@ExperimentalCarApi
const val ITEM_SIZE_MEDIUM = 2: Int
```

Represents a medium size for all grid items within a template.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setItemSize(int)` |   |

### ITEM_SIZE_SMALL

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
@ExperimentalCarApi
const val ITEM_SIZE_SMALL = 1: Int
```

Represents a small size for all grid items within a template. This is the default size.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setItemSize(int)` |   |

## Public functions

### equals

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

### getActionStrip

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
fun [getActionStrip](https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getActionStrip())(): ActionStrip?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header#getEndHeaderActions()` instead.

Returns the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ActionStrip` for this template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setActionStrip(androidx.car.app.model.ActionStrip)` |   |

### getActions

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
@ExperimentalCarApi
@RequiresCarApi(value = 7)
fun getActions(): (Mutable)List<Action!>
```

Returns the list of additional actions.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#addAction(androidx.car.app.model.Action)` |   |

### getHeader

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
fun getHeader(): Header?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header` to display in this template.

This method was introduced in API 7, but is backwards compatible even if the client is using API 6 or below.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setHeader(androidx.car.app.model.Header)` |   |

### getHeaderAction

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
fun [getHeaderAction](https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getHeaderAction())(): Action?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header#getStartHeaderAction()` instead.

Returns the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Action` that is set to be displayed in the header of the template, or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setHeaderAction(androidx.car.app.model.Action)` |   |

### getItemImageShape

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
@ExperimentalCarApi
fun getItemImageShape(): Int
```

Returns the item image shape.

All item images in the grid are cropped into the specified shape.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setItemImageShape(int)` |   |

### getItemSize

Added in [1.4.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.4.0)

```
@ExperimentalCarApi
fun getItemSize(): Int
```

Returns the grid item size, which applies to all grid items in the template.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setItemSize(int)` |   |

### getSingleList

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
fun getSingleList(): ItemList?
```

Returns the `https://developer.android.com/reference/kotlin/androidx/car/app/model/ItemList` instance that contains the grid items to display or `
null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setSingleList(androidx.car.app.model.ItemList)` |   |

### getTitle

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0) Deprecated in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
fun [getTitle](https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate#getTitle())(): CarText?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/car/app/model/Header#getTitle()` instead.

Returns the title of the template or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setTitle(java.lang.CharSequence)` |   |

### hashCode

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

### isLoading

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.0.0)

```
fun isLoading(): Boolean
```

Returns whether the template is loading.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/GridTemplate.Builder#setLoading(boolean)` |   |

### toString

```
fun toString(): String
```