Sdílet prostřednictvím


MotionEvent.GetRawX(Int32) Method

Definition

Returns the X coordinate of the pointer referenced by pointerIndex for this motion event.

[Android.Runtime.Register("getRawX", "(I)F", "", ApiSince=29)]
public float GetRawX (int pointerIndex);
[<Android.Runtime.Register("getRawX", "(I)F", "", ApiSince=29)>]
member this.GetRawX : int -> single

Parameters

pointerIndex
Int32

Index of the pointer for which the X coordinate is returned. May be a value in the range of 0 (the first pointer that is down) to #getPointerCount() - 1.

Returns

The X coordinate of the pointer referenced by pointerIndex for this motion event. The unit is pixels. The value may contain a fractional portion for devices that are subpixel precise.

Attributes

Remarks

Returns the X coordinate of the pointer referenced by pointerIndex for this motion event. The coordinate is in the coordinate space of the device display, irrespective of system decorations and whether or not the system is in multi-window mode. If the app spans multiple screens in a multiple-screen environment, the coordinate space includes all of the spanned screens.

In multi-window mode, the coordinate space extends beyond the bounds of the app window to encompass the entire display area. For example, if the motion event occurs in the right-hand window of split-screen mode in landscape orientation, the left edge of the screen&mdash;not the left edge of the window&mdash;is the origin from which the X 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 motion event occurs on the right-hand screen, the X coordinate is calculated from the left edge of the left-hand screen to the point of the motion event on the right-hand screen. 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.

Use #getPointerId(int) to get the pointer identifier for the pointer referenced by pointerIndex.

Java documentation for android.view.MotionEvent.getRawX(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