Share via


Configuration.ScreenWidthDp Property

Definition

The width of the available screen space in dp units excluding the area occupied by android.view.WindowInsets window insets.

[Android.Runtime.Register("screenWidthDp")]
public int ScreenWidthDp { get; set; }
[<Android.Runtime.Register("screenWidthDp")>]
member this.ScreenWidthDp : int with get, set

Property Value

Attributes

Remarks

The width of the available screen space in dp units excluding the area occupied by android.view.WindowInsets window insets.

"note"><b>Note:</b> The width measurement excludes window insets even when the app is displayed edge to edge using <c>android.view.Window#setDecorFitsSystemWindows(boolean) Window#setDecorFitsSystemWindows(boolean)</c>.</aside>

Corresponds to the available width resource qualifier. Defaults to #SCREEN_WIDTH_DP_UNDEFINED if no width is specified.

In multi-window mode, equals the width of the available display area of the app window, not the available display area of the device screen (for example, when apps are displayed side by side in split-screen mode in landscape orientation).

For embedded activities, equals the width of the individual activities, not the width of the app window or the device screen.

In multiple-screen scenarios, the width measurement can span screens. For example, if the app is spanning both screens of a dual-screen device (with the screens side by side), screenWidthDp represents the width of both screens excluding the area occupied by window insets. When the app is restricted to a single screen in a multiple-screen environment, screenWidthDp is the width of the screen on which the app is displayed excluding window insets.

Differs from android.view.WindowMetrics by not including window insets in the width measurement and by expressing the measurement in dp rather than px. Use screenWidthDp to obtain the width of the display area available to an app or embedded activity excluding the area occupied by window insets. Use android.view.WindowMetrics#getBounds() to obtain the horizontal display area available to an app or embedded activity including the area occupied by window insets.

Java documentation for android.content.res.Configuration.screenWidthDp.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to