# PreviewView.ImplementationMode

Artifact: [androidx.camera:camera-view](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/view/PreviewView.java+class:androidx.camera.view.PreviewView.ImplementationMode) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/camera#1.1.0)

*** ** * ** ***


```
public enum PreviewView.ImplementationMode
```

<br />

*** ** * ** ***

The implementation mode of a `https://developer.android.com/reference/androidx/camera/view/PreviewView`.

User preference on how the `https://developer.android.com/reference/androidx/camera/view/PreviewView` should render the preview. `https://developer.android.com/reference/androidx/camera/view/PreviewView` displays the preview with either a `https://developer.android.com/reference/android/view/SurfaceView.html` or a `https://developer.android.com/reference/android/view/TextureView.html`. A `https://developer.android.com/reference/android/view/SurfaceView.html` is generally better than a `https://developer.android.com/reference/android/view/TextureView.html` when it comes to certain key metrics, including power and latency. On the other hand, `https://developer.android.com/reference/android/view/TextureView.html` is better supported by a wider range of devices. The option is used by `https://developer.android.com/reference/androidx/camera/view/PreviewView` to decide what is the best internal implementation given the device capabilities and user configurations.

## Summary

| ### Enum Values |
|---|---|
| `https://developer.android.com/reference/androidx/camera/view/PreviewView.ImplementationMode#COMPATIBLE` | Use a `https://developer.android.com/reference/android/view/TextureView.html` for the preview. |
| `https://developer.android.com/reference/androidx/camera/view/PreviewView.ImplementationMode#PERFORMANCE` | Use a `https://developer.android.com/reference/android/view/SurfaceView.html` for the preview when possible. |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/androidx/camera/view/PreviewView.ImplementationMode` | `https://developer.android.com/reference/androidx/camera/view/PreviewView.ImplementationMode#valueOf(java.lang.String)(https://developer.android.com/reference/java/lang/String.html name)` Returns the enum constant of this type with the specified name. |
| `static PreviewView.ImplementationMode[]` | `https://developer.android.com/reference/androidx/camera/view/PreviewView.ImplementationMode#values()()` Returns an array containing the constants of this enum type, in the order they're declared. |

## Enum Values

### COMPATIBLE

```
PreviewView.ImplementationMode PreviewView.ImplementationMode.COMPATIBLE
```

Use a `https://developer.android.com/reference/android/view/TextureView.html` for the preview.

### PERFORMANCE

```
PreviewView.ImplementationMode PreviewView.ImplementationMode.PERFORMANCE
```

Use a `https://developer.android.com/reference/android/view/SurfaceView.html` for the preview when possible. If the device doesn't support `https://developer.android.com/reference/android/view/SurfaceView.html`, `https://developer.android.com/reference/androidx/camera/view/PreviewView` will fall back to use a `https://developer.android.com/reference/android/view/TextureView.html` instead.

`https://developer.android.com/reference/androidx/camera/view/PreviewView` falls back to `https://developer.android.com/reference/android/view/TextureView.html` when the API level is 24 or lower, the camera hardware support level is `https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY`, or `https://developer.android.com/reference/androidx/camera/core/Preview#getTargetRotation()` is different from `https://developer.android.com/reference/androidx/camera/view/PreviewView`'s display rotation.

Do not use this mode if `https://developer.android.com/reference/androidx/camera/core/Preview.Builder#setTargetRotation(int)` is set to a value different than the display's rotation, because `https://developer.android.com/reference/android/view/SurfaceView.html` does not support arbitrary rotations. Do not use this mode if the `https://developer.android.com/reference/androidx/camera/view/PreviewView` needs to be animated. `https://developer.android.com/reference/android/view/SurfaceView.html` animation is not supported on API level 24 or lower. Also, for the preview's streaming state provided in `https://developer.android.com/reference/androidx/camera/view/PreviewView#getPreviewStreamState()`, the `https://developer.android.com/reference/androidx/camera/view/PreviewView.StreamState#STREAMING` state might happen prematurely if this mode is used.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/camera/core/Preview.Builder#setTargetRotation(int)` |   |
| `https://developer.android.com/reference/androidx/camera/core/Preview#getTargetRotation()` |   |
| `https://developer.android.com/reference/android/view/Display.html#getRotation()` |   |
| `https://developer.android.com/reference/android/hardware/camera2/CameraMetadata.html#INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY` |   |
| `https://developer.android.com/reference/androidx/camera/view/PreviewView.StreamState#STREAMING` |   |

## Public methods

### valueOf

Added in 1.1.0

```
public static PreviewView.ImplementationMode valueOf(String name)
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/camera/view/PreviewView.ImplementationMode` | the enum constant with the specified name |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if this enum type has no constant with the specified name |

### values

Added in 1.1.0

```
public static PreviewView.ImplementationMode[] values()
```

Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants.

| Returns |
|---|---|
| `PreviewView.ImplementationMode[]` | an array containing the constants of this enum type, in the order they're declared |