View.GetLocationOnScreen(Int32[]) Method

Definition

Gets the coordinates of this view in the coordinate space of the device screen, irrespective of system decorations and whether the system is in multi-window mode.

[Android.Runtime.Register("getLocationOnScreen", "([I)V", "GetGetLocationOnScreen_arrayIHandler")]
public virtual void GetLocationOnScreen (int[]? outLocation);
[<Android.Runtime.Register("getLocationOnScreen", "([I)V", "GetGetLocationOnScreen_arrayIHandler")>]
abstract member GetLocationOnScreen : int[] -> unit
override this.GetLocationOnScreen : int[] -> unit

Parameters

outLocation
Int32[]

A two-element integer array in which the view coordinates are stored. The x-coordinate is at index 0; the y-coordinate, at index 1.

Attributes

Remarks

Gets the coordinates of this view in the coordinate space of the device screen, irrespective of system decorations and whether the system is in multi-window mode.

In multi-window mode, the coordinate space encompasses the entire device screen, ignoring the bounds of the app window. For example, if the view is in the bottom portion of a horizontal split screen, the top edge of the screen&mdash;not the top edge of the window&mdash;is the origin from which the y-coordinate is calculated.

In multiple-screen scenarios, the coordinate space can span screens. For example, if the app is spanning both screens of a dual-screen device and the view is located on the right-hand screen, the x-coordinate is calculated from the left edge of the left-hand screen to the left edge of the view. When the app is restricted to a single screen in a multiple-screen environment, the coordinate space includes only the screen on which the app is running.

After the method returns, the argument array contains the x and y coordinates of the view relative to the view's left and top edges, respectively.

Java documentation for android.view.View.getLocationOnScreen(int[]).

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