> 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)

*** ** * ** ***


```
class ScreenOrientation
```

<br />

*** ** * ** ***

Helper for resolving screen orientations.

## Summary

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

## Public functions

### getScreenOrientationFromRotation

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

```
java-static fun getScreenOrientationFromRotation(
    context: @UiContext Context,
    targetRotation: Int
): Int
```

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 |
|---|---|
| `context: @UiContext Context` | the visual UI `Context` (e.g., Activity or WindowContext) |
| `targetRotation: Int` | 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)

```
java-static fun isLandscape(context: @UiContext Context, targetRotation: Int): Boolean
```

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

| Parameters |
|---|---|
| `context: @UiContext Context` | the visual UI `Context` (e.g., Activity or WindowContext) |
| `targetRotation: Int` | 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)

```
java-static fun isPortrait(context: @UiContext Context, targetRotation: Int): Boolean
```

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

| Parameters |
|---|---|
| `context: @UiContext Context` | the visual UI `Context` (e.g., Activity or WindowContext) |
| `targetRotation: Int` | 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 |