Display.GetSize(Point) Method

Definition

Gets the size of the display in pixels.

[Android.Runtime.Register("getSize", "(Landroid/graphics/Point;)V", "GetGetSize_Landroid_graphics_Point_Handler")]
public virtual void GetSize (Android.Graphics.Point? outSize);
[<Android.Runtime.Register("getSize", "(Landroid/graphics/Point;)V", "GetGetSize_Landroid_graphics_Point_Handler")>]
abstract member GetSize : Android.Graphics.Point -> unit
override this.GetSize : Android.Graphics.Point -> unit

Parameters

outSize
Point

A Point object which receives the display size information.

Attributes

Remarks

Gets the size of the display in pixels.

The return value does not necessarily represent the actual size (native resolution) of the display. The returned size might be adjusted to exclude certain system decor elements that are always visible, or the size might be scaled to provide compatibility with older applications that were originally designed for smaller displays.

The returned size can also be different depending on the WindowManager bound to the display: <ul> <li>If size is requested from an activity (either using a WindowManager accessed by getWindowManager() or getSystemService(Context.WINDOW_SERVICE)), the size of the current app window is returned. As a result, in multi-window mode, the returned size can be smaller than the size of the device screen. <li>If size is requested from a non-activity context (for example, the application context, where the WindowManager is accessed by getApplicationContext().getSystemService(Context.WINDOW_SERVICE)), the returned size can vary depending on API level: <ul> <li>API level 29 and below &mdash; The size of the entire display (based on current rotation) minus system decoration areas is returned. <li>API level 30 and above &mdash; The size of the top running activity in the current process is returned. If the current process has no running activities, the size of the device default display, including system decoration areas, is returned. </ul> </ul>

For layout purposes, apps should make a request from an activity context to obtain the size of the display area available for app content.

This member is deprecated. Use WindowMetrics instead. Obtain a WindowMetrics instance by calling WindowManager#getCurrentWindowMetrics(), then call WindowMetrics#getBounds() to get the dimensions of the application window.

Java documentation for android.view.Display.getSize(android.graphics.Point).

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