Added in API level 9

PointerCoords


class PointerCoords
kotlin.Any
   ↳ android.view.MotionEvent.PointerCoords

Transfer object for pointer coordinates. Objects of this type can be used to specify the pointer coordinates when creating new MotionEvent objects and to query pointer coordinates in bulk. Refer to InputDevice for information about how different kinds of input devices and sources represent pointer coordinates.

Summary

Public constructors

Creates a pointer coords object with all axes initialized to zero.

Creates a pointer coords object as a copy of the contents of another pointer coords object.

Public methods
Unit

Clears the contents of this object.

Unit

Copies the contents of another pointer coords object.

Float

Gets the value associated with the specified axis.

Boolean

Returns true if these pointer coordinates were generated by resampling, rather than from an actual input event from the device at this time.

Unit
setAxisValue(axis: Int, value: Float)

Sets the value associated with the specified axis.

Properties
Float

The orientation of the touch area and tool area in radians clockwise from vertical.

Float

A normalized value that describes the pressure applied to the device by a finger or other tool.

Float

A normalized value that describes the approximate size of the pointer touch area in relation to the maximum detectable size of the device.

Float

The length of the major axis of an ellipse that describes the size of the approaching tool.

Float

The length of the minor axis of an ellipse that describes the size of the approaching tool.

Float

The length of the major axis of an ellipse that describes the touch area at the point of contact.

Float

The length of the minor axis of an ellipse that describes the touch area at the point of contact.

Float

The X component of the pointer movement.

Float

The Y component of the pointer movement.

Public constructors

PointerCoords

Added in API level 9
PointerCoords()

Creates a pointer coords object with all axes initialized to zero.

PointerCoords

Added in API level 12
PointerCoords(other: MotionEvent.PointerCoords!)

Creates a pointer coords object as a copy of the contents of another pointer coords object.

Parameters
other MotionEvent.PointerCoords!: The pointer coords object to copy.

Public methods

clear

Added in API level 12
fun clear(): Unit

Clears the contents of this object. Resets all axes to zero.

copyFrom

Added in API level 12
fun copyFrom(other: MotionEvent.PointerCoords!): Unit

Copies the contents of another pointer coords object.

Parameters
other MotionEvent.PointerCoords!: The pointer coords object to copy.

getAxisValue

Added in API level 12
fun getAxisValue(axis: Int): Float

Gets the value associated with the specified axis.

Parameters
axis Int: The axis identifier for the axis value to retrieve.
Return
Float The value associated with the axis, or 0 if none.

isResampled

Added in API level 35
fun isResampled(): Boolean

Returns true if these pointer coordinates were generated by resampling, rather than from an actual input event from the device at this time.

Resampling extrapolates or interpolates touch coordinates reported by the input device to better align them with the refresh rate of the display, resulting in smoother movements, in particular for scrolling. Resampled coordinates are always added to batches, so a motion event will always contain at least one sample that is an original event from the input device (i.e. for which this method will return false).

Resampling does not occur if unbuffered dispatch has been requested, or if it has been disabled by the manufacturer (for example, on hardware that already synchronizes its touch events and display frames).

setAxisValue

Added in API level 12
fun setAxisValue(
    axis: Int,
    value: Float
): Unit

Sets the value associated with the specified axis.

Parameters
axis Int: The axis identifier for the axis value to assign.
value Float: The value to set.

Properties

orientation

Added in API level 9
var orientation: Float

The orientation of the touch area and tool area in radians clockwise from vertical. An angle of 0 radians indicates that the major axis of contact is oriented upwards, is perfectly circular or is of unknown orientation. A positive angle indicates that the major axis of contact is oriented to the right. A negative angle indicates that the major axis of contact is oriented to the left. The full range is from -PI/2 radians (finger pointing fully left) to PI/2 radians (finger pointing fully right).

pressure

Added in API level 9
var pressure: Float

A normalized value that describes the pressure applied to the device by a finger or other tool. The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), although values higher than 1 may be generated depending on the calibration of the input device.

size

Added in API level 9
var size: Float

A normalized value that describes the approximate size of the pointer touch area in relation to the maximum detectable size of the device. It represents some approximation of the area of the screen being pressed; the actual value in pixels corresponding to the touch is normalized with the device specific range of values and scaled to a value between 0 and 1. The value of size can be used to determine fat touch events.

toolMajor

Added in API level 9
var toolMajor: Float

The length of the major axis of an ellipse that describes the size of the approaching tool. The tool area represents the estimated size of the finger or pen that is touching the device independent of its actual touch area at the point of contact. If the device is a touch screen, the length is reported in pixels, otherwise it is reported in device-specific units.

toolMinor

Added in API level 9
var toolMinor: Float

The length of the minor axis of an ellipse that describes the size of the approaching tool. The tool area represents the estimated size of the finger or pen that is touching the device independent of its actual touch area at the point of contact. If the device is a touch screen, the length is reported in pixels, otherwise it is reported in device-specific units.

touchMajor

Added in API level 9
var touchMajor: Float

The length of the major axis of an ellipse that describes the touch area at the point of contact. If the device is a touch screen, the length is reported in pixels, otherwise it is reported in device-specific units.

touchMinor

Added in API level 9
var touchMinor: Float

The length of the minor axis of an ellipse that describes the touch area at the point of contact. If the device is a touch screen, the length is reported in pixels, otherwise it is reported in device-specific units.

x

Added in API level 9
var x: Float

The X component of the pointer movement.

y

Added in API level 9
var y: Float

The Y component of the pointer movement.