Display.GetRealSize(Point) Method

Definition

Gets the size of the largest region of the display accessible to an app in the current system state, without subtracting any window decor or applying scaling factors.

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

Parameters

outSize
Point

Set to the real size of the display.

Attributes

Remarks

Gets the size of the largest region of the display accessible to an app in the current system state, without subtracting any window decor or applying scaling factors.

The size is adjusted based on the current rotation of the display.

The returned size will fall into one of these scenarios: <ol> <li>The device has no partitions on the display. The returned value is the largest region of the display accessible to an app in the current system state, regardless of windowing mode.</li> <li>The device divides a single display into multiple partitions. An application is restricted to a portion of the display. This is common in devices where the display changes size, such as foldables or large screens. The returned size will match the portion of the display the application is restricted to.</li> <li>The window manager is emulating a different display size, using adb shell wm size. The returned size will match the emulated display size.</li> </ol> </p>

The returned value is <b>unsuitable to use when sizing and placing UI elements</b>, since it does not reflect the application window size in any of these scenarios. WindowManager#getCurrentWindowMetrics() is an alternative that returns the size of the current application window, even if the window is on a device with a partitioned display. This helps prevent UI bugs where UI elements are misaligned or placed beyond the bounds of the window.

Handling multi-window mode correctly is necessary since applications are not always fullscreen. A user on a large screen device, such as a tablet or ChromeOS devices, is more likely to use multi-window modes.

For example, consider a device with a display partitioned into two halves. The user may have a fullscreen application open on the first partition. They may have two applications open in split screen (an example of multi-window mode) on the second partition, with each application consuming half of the partition. In this case, WindowManager#getCurrentWindowMetrics() reports the fullscreen window is half of the screen in size, and each split screen window is a quarter of the screen in size. On the other hand, #getRealSize reports half of the screen size for all windows, since the application windows are all restricted to their respective partitions. </p>

This member is deprecated. Use WindowManager#getCurrentWindowMetrics() to identify the current size of the activity window. UI-related work, such as choosing UI layouts, should rely upon WindowMetrics#getBounds().

Java documentation for android.view.Display.getRealSize(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