# Background.Builder

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/Background.java+class:androidx.car.app.model.Background.Builder) Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

*** ** * ** ***


```
class Background.Builder
```

<br />

*** ** * ** ***

A builder of `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder#Builder()()` Returns an empty `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder` instance. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder#Builder(androidx.car.app.model.Background)(background: https://developer.android.com/reference/kotlin/androidx/car/app/model/Background)` Returns a new `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder` with the data from the given `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background` instance. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder#build()()` Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background` defined by this builder. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder#setColor(androidx.car.app.model.CarColor)(color: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor` to be used for the background. |
| `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder` | `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder#setImage(androidx.car.app.model.CarIcon)(image: https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon)` Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` that will be displayed as the background. |

## Public constructors

### Builder

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

```
Builder()
```

Returns an empty `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder` instance.

### Builder

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

```
Builder(background: Background)
```

Returns a new `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background.Builder` with the data from the given `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background` instance.

## Public functions

### build

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

```
fun build(): Background
```

Constructs the `https://developer.android.com/reference/kotlin/androidx/car/app/model/Background` defined by this builder.

Ensures that exactly one of either an image or a color is set for the background.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if neither an image nor a color is set, or if both an image and a color are set. |

### setColor

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

```
fun setColor(color: CarColor): Background.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarColor` to be used for the background.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `color` is `null` |

### setImage

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

```
fun setImage(image: CarIcon): Background.Builder
```

Sets the `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon` that will be displayed as the background.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if `image` is `null` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `image` is not of type `https://developer.android.com/reference/kotlin/androidx/car/app/model/CarIcon#TYPE_CUSTOM()` |