# DisplayCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/view/DisplayCompat.java+class:androidx.core.view.DisplayCompat)  
Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/core#1.3.0)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/core/view/DisplayCompat "View this page in Java")


```
class DisplayCompat
```

<br />

*** ** * ** ***

A class for retrieving accurate display modes for a display.

On many Android TV devices, Display.Mode may not report the accurate width and height because these devices do not have powerful enough graphics pipelines to run framework code at the same resolutions supported by their video pipelines. For these devices, there is no way for an app to determine, for example, whether or not the current display mode is 4k, or that the display supports switching to other 4k modes. This class offers a workaround for this problem.

## Summary

| ### Nested types |
|---|
| `class `[DisplayCompat.ModeCompat](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayCompat.ModeCompat) Compat class which provides access to the underlying display mode, if there is one, and a more reliable display mode size. |

| ### Public functions |
|---|---|
| `java-static `[DisplayCompat.ModeCompat](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayCompat.ModeCompat) | [getMode](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayCompat#getMode(android.content.Context,android.view.Display))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, display: `[Display](https://developer.android.com/reference/android/view/Display.html)`)` Gets the current display mode of the given display, where the size can be relied on to determine support for 4k on Android TV devices. |
| `java-static `[RoundedCornerCompat](https://developer.android.com/reference/kotlin/androidx/core/view/RoundedCornerCompat)`?` | [getRoundedCorner](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayCompat#getRoundedCorner(android.view.Display,int))`(display: `[Display](https://developer.android.com/reference/android/view/Display.html)`, position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Returns the [RoundedCornerCompat](https://developer.android.com/reference/kotlin/androidx/core/view/RoundedCornerCompat) of the given position if there is one. |
| `java-static `[DisplayShapeCompat](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayShapeCompat) | [getShape](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayCompat#getShape(android.content.Context,android.view.Display))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, display: `[Display](https://developer.android.com/reference/android/view/Display.html)`)` Returns the [DisplayShapeCompat](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayShapeCompat) of the given display. |
| `java-static `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[DisplayCompat.ModeCompat](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayCompat.ModeCompat)`!>` | [getSupportedModes](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayCompat#getSupportedModes(android.content.Context,android.view.Display))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`, display: `[Display](https://developer.android.com/reference/android/view/Display.html)`)` Gets the supported modes of the given display where any mode with the same size as the current mode can be relied on to determine support for 4k on Android TV devices. |

## Public functions

### getMode

Added in [1.6.0](https://developer.android.com/jetpack/androidx/releases/core#1.6.0)  

```
java-static fun getMode(context: Context, display: Display): DisplayCompat.ModeCompat
```

Gets the current display mode of the given display, where the size can be relied on to determine support for 4k on Android TV devices.  

### getRoundedCorner

Added in [1.16.0](https://developer.android.com/jetpack/androidx/releases/core#1.16.0)  

```
java-static fun getRoundedCorner(display: Display, position: Int): RoundedCornerCompat?
```

Returns the [RoundedCornerCompat](https://developer.android.com/reference/kotlin/androidx/core/view/RoundedCornerCompat) of the given position if there is one.  

| Parameters |
|---|---|
| `display: `[Display](https://developer.android.com/reference/android/view/Display.html) | the given display. |
| `position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the position of the rounded corner on the display. |

| Returns |
|---|---|
| [RoundedCornerCompat](https://developer.android.com/reference/kotlin/androidx/core/view/RoundedCornerCompat)`?` | the rounded corner of the given position. Returns `null` if there is none. |

### getShape

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

```
java-static fun getShape(context: Context, display: Display): DisplayShapeCompat
```

Returns the [DisplayShapeCompat](https://developer.android.com/reference/kotlin/androidx/core/view/DisplayShapeCompat) of the given display.  

### getSupportedModes

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/core#1.3.0)  

```
java-static fun getSupportedModes(context: Context, display: Display): Array<DisplayCompat.ModeCompat!>
```

Gets the supported modes of the given display where any mode with the same size as the current mode can be relied on to determine support for 4k on Android TV devices.