# Background

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

*** ** * ** ***


```
@CarProtocol
@ExperimentalCarApi
@RequiresCarApi(value = 9)
public final class Background
```

<br />

*** ** * ** ***

A background for a user interface component.

The image or color will be modified to ensure safe a color contrast ratio with the content.

The background can be set as either a solid color using `https://developer.android.com/reference/androidx/car/app/model/CarColor` or an image using `https://developer.android.com/reference/androidx/car/app/model/CarIcon`. Only one of these can be set at a time.

## Summary

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

| ### Constants |
|---|---|
| `static final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Background` | `https://developer.android.com/reference/androidx/car/app/model/Background#TRANSPARENT()` A transparent background. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/Background#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarColor` | `https://developer.android.com/reference/androidx/car/app/model/Background#getColor()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/CarColor` used for the background, or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarIcon` | `https://developer.android.com/reference/androidx/car/app/model/Background#getImage()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/CarIcon` associated with this background, or `null` if not set. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/Background#hashCode()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/Background#toString()()` |

## Constants

### TRANSPARENT

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

```
public static final @NonNull Background TRANSPARENT
```

A transparent background.

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### getColor

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

```
public @Nullable CarColor getColor()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/CarColor` used for the background, or `null` if not set.

### getImage

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

```
public @Nullable CarIcon getImage()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/CarIcon` associated with this background, or `null` if not set.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```