# Banner

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

*** ** * ** ***


```
@ExperimentalCarApi
@CarProtocol
@RequiresCarApi(value = 9)
public final class Banner implements Item
```

<br />

*** ** * ** ***

A banner element that's meant to be visually distinct from other normal elements on the screen.

For example, a banner can be used to tell the user whether the app is running in an online vs offline mode, or promote a specific event or announcement.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 9) @https://developer.android.com/reference/androidx/car/app/annotations/ExperimentalCarApi public final class https://developer.android.com/reference/androidx/car/app/model/Banner.Builder` A builder of `https://developer.android.com/reference/androidx/car/app/model/Banner`. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/Banner#IMAGE_TYPE_LARGE() = 3` Represents a large edge-to-edge image to be displayed in the banner. |
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/Banner#IMAGE_TYPE_MEDIUM() = 2` Represents a medium padded artwork image to be displayed in the banner. |
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/Banner#IMAGE_TYPE_SMALL() = 1` Represents a small icon-sized image to be displayed in the banner. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/Banner#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/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/car/app/model/Action>` | `https://developer.android.com/reference/androidx/car/app/model/Banner#getBelowActions()()` Returns the list of actions below the title and subtitle. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/BannerElement` | `https://developer.android.com/reference/androidx/car/app/model/Banner#getLeadingElement()()` Returns the leading element of the banner. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/OnClickDelegate` | `https://developer.android.com/reference/androidx/car/app/model/Banner#getOnClickDelegate()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/OnClickDelegate` to be called back when the banner is clicked. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/BannerStyle` | `https://developer.android.com/reference/androidx/car/app/model/Banner#getStyle()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/BannerStyle` of the banner, or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `https://developer.android.com/reference/androidx/car/app/model/Banner#getSubtitle()()` Returns the subtitle of the banner. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `https://developer.android.com/reference/androidx/car/app/model/Banner#getTitle()()` Returns the title of the banner. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/car/app/model/BannerElement>` | `https://developer.android.com/reference/androidx/car/app/model/Banner#getTrailingElements()()` Returns the list of trailing elements of the banner. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/Banner#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/Banner#toString()()` |

## Constants

### IMAGE_TYPE_LARGE

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

```
public static final int IMAGE_TYPE_LARGE = 3
```

Represents a large edge-to-edge image to be displayed in the banner. Scales the image to fill the container and potentially clip within the bounds if a shape is applied.

This image type cannot be used in combination with `https://developer.android.com/reference/androidx/car/app/model/Banner.Builder#addBelowAction(androidx.car.app.model.Action)`.

### IMAGE_TYPE_MEDIUM

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

```
public static final int IMAGE_TYPE_MEDIUM = 2
```

Represents a medium padded artwork image to be displayed in the banner.

The host renders it with standard padding and scales the image to fit within the bounds.

### IMAGE_TYPE_SMALL

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

```
public static final int IMAGE_TYPE_SMALL = 1
```

Represents a small icon-sized image to be displayed in the banner.

The host renders it with standard padding and scales the image to fit within the bounds.

## Public methods

### equals

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

### getBelowActions

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

```
public @NonNull List<Action> getBelowActions()
```

Returns the list of actions below the title and subtitle.

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

### getLeadingElement

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

```
public @Nullable BannerElement getLeadingElement()
```

Returns the leading element of the banner.

This is currently restricted to icons and images only.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Banner.Builder#setLeadingImage(androidx.car.app.model.CarIcon)` |   |
| `https://developer.android.com/reference/androidx/car/app/model/Banner.Builder#setLeadingImage(androidx.car.app.model.CarIcon,int)` |   |

### getOnClickDelegate

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

```
public @Nullable OnClickDelegate getOnClickDelegate()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/OnClickDelegate` to be called back when the banner is clicked.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Banner.Builder#setOnClickListener(androidx.car.app.model.OnClickListener)` |   |

### getStyle

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

```
public @Nullable BannerStyle getStyle()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/BannerStyle` of the banner, or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Banner.Builder#setStyle(androidx.car.app.model.BannerStyle)` |   |

### getSubtitle

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

```
public @Nullable CarText getSubtitle()
```

Returns the subtitle of the banner.

The subtitle is automatically truncated if it's too long; however, shorter variants can be added via `https://developer.android.com/reference/androidx/car/app/model/CarText.Builder#addVariant(java.lang.CharSequence)`.

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

### getTitle

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

```
public @Nullable CarText getTitle()
```

Returns the title of the banner.

The title is automatically truncated if it's too long; however, shorter variants can be added via `https://developer.android.com/reference/androidx/car/app/model/CarText.Builder#addVariant(java.lang.CharSequence)`.

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

### getTrailingElements

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

```
public @NonNull List<BannerElement> getTrailingElements()
```

Returns the list of trailing elements of the banner.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/Banner.Builder#addTrailingAction(androidx.car.app.model.Action)` |   |
| `https://developer.android.com/reference/androidx/car/app/model/Banner.Builder#addTrailingImage(androidx.car.app.model.CarIcon)` |   |
| `https://developer.android.com/reference/androidx/car/app/model/Banner.Builder#addTrailingImage(androidx.car.app.model.CarIcon,int)` |   |

### hashCode

```
public int hashCode()
```

### toString

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