# 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
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/kotlin/androidx/car/app/SurfaceContainer#SurfaceContainer(android.view.Surface,int,int,int)(surface: https://developer.android.com/reference/android/view/Surface.html?, width: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, height: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, dpi: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/SurfaceContainer#getDpi()()` Returns the pixel density of the surface or 0 if the surface is not ready. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/SurfaceContainer#getHeight()()` Returns the height of the surface or 0 if the surface is not ready. |
| `https://developer.android.com/reference/android/view/Surface.html?` | `https://developer.android.com/reference/kotlin/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. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/car/app/SurfaceContainer#getWidth()()` Returns the width of the surface or 0 if the surface is not ready. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/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)

```
SurfaceContainer(surface: Surface?, width: Int, height: Int, dpi: Int)
```

## Public functions

### getDpi

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

```
fun getDpi(): Int
```

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)

```
fun getHeight(): Int
```

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)

```
fun getSurface(): Surface?
```

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)

```
fun getWidth(): Int
```

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

### toString

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