> Documentation index: https://developer.android.com/reference/llms.txt

# ScreenOrientation

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core.md.txt) [View Source](https://cs.android.com/search?q=file:androidx/core/view/ScreenOrientation.java+class:androidx.core.view.ScreenOrientation) Added in [1.20.0-alpha01](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.20.0-alpha01)

*** ** * ** ***


```
public final class ScreenOrientation
```

<br />

*** ** * ** ***

Helper for resolving screen orientations.

## Summary

| ### Public methods |
|---|---|
| `static int` | `getScreenOrientationFromRotation( @NonNull @UiContext Context context, int targetRotation )` Resolves a raw rotation angle into one of the four 4-way screen orientations relative to the specified UI `Context`. |
| `static boolean` | `isLandscape(@NonNull @UiContext Context context, int targetRotation)` Resolves a raw rotation angle for the specified UI `Context` and returns whether the resulting visual orientation is landscape (landscape or reverse landscape). |
| `static boolean` | `isPortrait(@NonNull @UiContext Context context, int targetRotation)` Resolves a raw rotation angle for the specified UI `Context` and returns whether the resulting visual orientation is portrait (portrait or reverse portrait). |

## Public methods

### getScreenOrientationFromRotation

Added in [1.20.0-alpha01](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.20.0-alpha01)

```
public static int getScreenOrientationFromRotation(
    @NonNull @UiContext Context context,
    int targetRotation
)
```

Resolves a raw rotation angle into one of the four 4-way screen orientations relative to the specified UI `Context`.

Raw rotation values (such as those from rotation sensors or `getRotation`) do not always map directly to standard screen orientations. For example, on landscape-natural devices (such as many tablets and foldables), `ROTATION_0` corresponds to landscape rather than portrait, and devices with reverse-default rotation configurations invert 90-degree and 270-degree rotation directions.

**Note:** For general static layout decisions, applications should rely directly on `orientation` via `context.getResources().getConfiguration().orientation`. Use this method when converting rotation angles into `ActivityInfo` screen orientation constants.

| Parameters |
|---|---|
| `@NonNull @UiContext Context context` | the visual UI `Context` (e.g., Activity or WindowContext) |
| `int targetRotation` | the rotation angle to evaluate, defined by `Surface` constants (e.g., `ROTATION_0`, `ROTATION_90`, `ROTATION_180`, or `ROTATION_270`) Value is one of the following: - `Surface.ROTATION_0` - `Surface.ROTATION_90` - `Surface.ROTATION_180` - `Surface.ROTATION_270` <br /> |

| Returns |
|---|---|
| `int` | one of the four screen orientation constants: `SCREEN_ORIENTATION_PORTRAIT`, `SCREEN_ORIENTATION_LANDSCAPE`, `SCREEN_ORIENTATION_REVERSE_PORTRAIT`, or `SCREEN_ORIENTATION_REVERSE_LANDSCAPE` |

### isLandscape

Added in [1.20.0-alpha01](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.20.0-alpha01)

```
public static boolean isLandscape(@NonNull @UiContext Context context, int targetRotation)
```

Resolves a raw rotation angle for the specified UI `Context` and returns whether the resulting visual orientation is landscape (landscape or reverse landscape).

| Parameters |
|---|---|
| `@NonNull @UiContext Context context` | the visual UI `Context` (e.g., Activity or WindowContext) |
| `int targetRotation` | the rotation angle to evaluate, defined by `Surface` constants (e.g., `ROTATION_0`, `ROTATION_90`, `ROTATION_180`, or `ROTATION_270`) Value is one of the following: - `Surface.ROTATION_0` - `Surface.ROTATION_90` - `Surface.ROTATION_180` - `Surface.ROTATION_270` <br /> |

| Returns |
|---|---|
| `boolean` | `true` if the target rotation maps to a landscape screen orientation; `false` otherwise |

### isPortrait

Added in [1.20.0-alpha01](https://developer.android.com/jetpack/androidx/releases/core.md.txt#1.20.0-alpha01)

```
public static boolean isPortrait(@NonNull @UiContext Context context, int targetRotation)
```

Resolves a raw rotation angle for the specified UI `Context` and returns whether the resulting visual orientation is portrait (portrait or reverse portrait).

| Parameters |
|---|---|
| `@NonNull @UiContext Context context` | the visual UI `Context` (e.g., Activity or WindowContext) |
| `int targetRotation` | the rotation angle to evaluate, defined by `Surface` constants (e.g., `ROTATION_0`, `ROTATION_90`, `ROTATION_180`, or `ROTATION_270`) Value is one of the following: - `Surface.ROTATION_0` - `Surface.ROTATION_90` - `Surface.ROTATION_180` - `Surface.ROTATION_270` <br /> |

| Returns |
|---|---|
| `boolean` | `true` if the target rotation maps to a portrait screen orientation; `false` otherwise |