# SurfaceContainer

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

*** ** * ** ***


```
@CarProtocol
public final class SurfaceContainer
```

<br />

*** ** * ** ***

A container for the `https://developer.android.com/reference/android/view/Surface.html` created by the host and its associated properties.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/SurfaceContainer#SurfaceContainer(android.view.Surface,int,int,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/Surface.html surface, int width, int height, int dpi)` |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/car/app/SurfaceContainer#getDpi()()` Returns the pixel density of the surface or 0 if the surface is not ready. |
| `int` | `https://developer.android.com/reference/androidx/car/app/SurfaceContainer#getHeight()()` Returns the height of the surface or 0 if the surface is not ready. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/Surface.html` | `https://developer.android.com/reference/androidx/car/app/SurfaceContainer#getSurface()()` Returns the `https://developer.android.com/reference/android/view/Surface.html` held by the host or `null` if the surface is not ready. |
| `int` | `https://developer.android.com/reference/androidx/car/app/SurfaceContainer#getWidth()()` Returns the width of the surface or 0 if the surface is not ready. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/SurfaceContainer#toString()()` |

## Public constructors

### SurfaceContainer

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

```
public SurfaceContainer(@Nullable Surface surface, int width, int height, int dpi)
```

## Public methods

### getDpi

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

```
public int getDpi()
```

Returns the pixel density of the surface or 0 if the surface is not ready.

### getHeight

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

```
public int getHeight()
```

Returns the height of the surface or 0 if the surface is not ready.

### getSurface

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

```
public @Nullable Surface getSurface()
```

Returns the `https://developer.android.com/reference/android/view/Surface.html` held by the host or `null` if the surface is not ready.

### getWidth

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

```
public int getWidth()
```

Returns the width of the surface or 0 if the surface is not ready.

### toString

```
public String toString()
```