Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

MotionEventCompat

class MotionEventCompat
kotlin.Any
   ↳ androidx.core.view.MotionEventCompat

Helper for accessing features in MotionEvent.

Summary

Constants
static Int

Synonym for MotionEvent#ACTION_HOVER_ENTER.

static Int

Synonym for MotionEvent#ACTION_HOVER_EXIT.

static Int

Synonym for MotionEvent#ACTION_HOVER_MOVE.

static Int

Synonym for MotionEvent#ACTION_MASK.

static Int

Synonym for MotionEvent#ACTION_POINTER_DOWN.

static Int

Synonym for MotionEvent#ACTION_POINTER_INDEX_MASK.

static Int

Synonym for MotionEvent#ACTION_POINTER_INDEX_SHIFT.

static Int

Synonym for MotionEvent#ACTION_POINTER_UP.

static Int

Synonym for MotionEvent#ACTION_SCROLL.

static Int

Synonym for MotionEvent#AXIS_BRAKE.

static Int

Synonym for MotionEvent#AXIS_DISTANCE.

static Int

Synonym for MotionEvent#AXIS_GAS.

static Int

Synonym for MotionEvent#AXIS_GENERIC_1.

static Int

Synonym for MotionEvent#AXIS_GENERIC_10.

static Int

Synonym for MotionEvent#AXIS_GENERIC_11.

static Int

Synonym for MotionEvent#AXIS_GENERIC_12.

static Int

Synonym for MotionEvent#AXIS_GENERIC_13.

static Int

Synonym for MotionEvent#AXIS_GENERIC_14.

static Int

Synonym for MotionEvent#AXIS_GENERIC_15.

static Int

Synonym for MotionEvent#AXIS_GENERIC_16.

static Int

Synonym for MotionEvent#AXIS_GENERIC_2.

static Int

Synonym for MotionEvent#AXIS_GENERIC_3.

static Int

Synonym for MotionEvent#AXIS_GENERIC_4.

static Int

Synonym for MotionEvent#AXIS_GENERIC_5.

static Int

Synonym for MotionEvent#AXIS_GENERIC_6.

static Int

Synonym for MotionEvent#AXIS_GENERIC_7.

static Int

Synonym for MotionEvent#AXIS_GENERIC_8.

static Int

Synonym for MotionEvent#AXIS_GENERIC_9.

static Int

Synonym for MotionEvent#AXIS_HAT_X.

static Int

Synonym for MotionEvent#AXIS_HAT_Y.

static Int

Synonym for MotionEvent#AXIS_HSCROLL.

static Int

Synonym for MotionEvent#AXIS_LTRIGGER.

static Int

Synonym for MotionEvent#AXIS_ORIENTATION.

static Int

Synonym for MotionEvent#AXIS_PRESSURE.

static Int

Synonym for MotionEvent#AXIS_RELATIVE_X.

static Int

Synonym for MotionEvent#AXIS_RELATIVE_Y.

static Int

Synonym for MotionEvent#AXIS_RTRIGGER.

static Int

Synonym for MotionEvent#AXIS_RUDDER.

static Int

Synonym for MotionEvent#AXIS_RX.

static Int

Synonym for MotionEvent#AXIS_RY.

static Int

Synonym for MotionEvent#AXIS_RZ.

static Int

Synonym for MotionEvent#AXIS_SCROLL.

static Int

Synonym for MotionEvent#AXIS_SIZE.

static Int

Synonym for MotionEvent#AXIS_THROTTLE.

static Int

Synonym for MotionEvent#AXIS_TILT.

static Int

Synonym for MotionEvent#AXIS_TOOL_MAJOR.

static Int

Synonym for MotionEvent#AXIS_TOOL_MINOR.

static Int

Synonym for MotionEvent#AXIS_TOUCH_MAJOR.

static Int

Synonym for MotionEvent#AXIS_TOUCH_MINOR.

static Int

Synonym for MotionEvent#AXIS_VSCROLL.

static Int

Synonym for MotionEvent#AXIS_WHEEL.

static Int

Synonym for MotionEvent#AXIS_X.

static Int

Synonym for MotionEvent#AXIS_Y.

static Int

Synonym for MotionEvent#AXIS_Z.

static Int

Synonym for MotionEvent#BUTTON_PRIMARY.

Public methods
static Int
findPointerIndex(event: MotionEvent!, pointerId: Int)

Call MotionEvent#findPointerIndex(int).

static Int

Call MotionEvent#getAction, returning only the pointer index portion.

static Int

Call MotionEvent#getAction, returning only the ACTION_MASK portion.

static Float
getAxisValue(event: MotionEvent!, axis: Int)

Get axis value for the first pointer index (may be an arbitrary pointer identifier).

static Float
getAxisValue(event: MotionEvent!, axis: Int, pointerIndex: Int)

Returns the value of the requested axis for the given pointer index (use getPointerId(MotionEvent, int) to find the pointer identifier for this index).

static Int

static Int

The number of pointers of data contained in this event.

static Int
getPointerId(event: MotionEvent!, pointerIndex: Int)

Call MotionEvent#getPointerId(int).

static Int

Gets the source of the event.

static Float
getX(event: MotionEvent!, pointerIndex: Int)

Call MotionEvent#getX(int).

static Float
getY(event: MotionEvent!, pointerIndex: Int)

Call MotionEvent#getY(int).

static Boolean
isFromSource(event: MotionEvent!, source: Int)

Determines whether the event is from the given source.

Constants

ACTION_HOVER_ENTER

static val ACTION_HOVER_ENTER: Int

Synonym for MotionEvent#ACTION_HOVER_ENTER.

Value: 9

ACTION_HOVER_EXIT

static val ACTION_HOVER_EXIT: Int

Synonym for MotionEvent#ACTION_HOVER_EXIT.

Value: 10

ACTION_HOVER_MOVE

static val ACTION_HOVER_MOVE: Int

Synonym for MotionEvent#ACTION_HOVER_MOVE.

Value: 7

ACTION_MASK

static val ACTION_MASK: Int

Synonym for MotionEvent#ACTION_MASK.

Value: 0xff

ACTION_POINTER_DOWN

static val ACTION_POINTER_DOWN: Int

Synonym for MotionEvent#ACTION_POINTER_DOWN.

Value: 5

ACTION_POINTER_INDEX_MASK

static val ACTION_POINTER_INDEX_MASK: Int

Synonym for MotionEvent#ACTION_POINTER_INDEX_MASK.

Value: 0xff00

ACTION_POINTER_INDEX_SHIFT

static val ACTION_POINTER_INDEX_SHIFT: Int

Synonym for MotionEvent#ACTION_POINTER_INDEX_SHIFT.

Value: 8

ACTION_POINTER_UP

static val ACTION_POINTER_UP: Int

Synonym for MotionEvent#ACTION_POINTER_UP.

Value: 6

ACTION_SCROLL

static val ACTION_SCROLL: Int

Synonym for MotionEvent#ACTION_SCROLL.

Value: 8

AXIS_BRAKE

static val AXIS_BRAKE: Int

Synonym for MotionEvent#AXIS_BRAKE.

Value: 23

AXIS_DISTANCE

static val AXIS_DISTANCE: Int

Synonym for MotionEvent#AXIS_DISTANCE.

Value: 24

AXIS_GAS

static val AXIS_GAS: Int

Synonym for MotionEvent#AXIS_GAS.

Value: 22

AXIS_GENERIC_1

static val AXIS_GENERIC_1: Int

Synonym for MotionEvent#AXIS_GENERIC_1.

Value: 32

AXIS_GENERIC_10

static val AXIS_GENERIC_10: Int

Synonym for MotionEvent#AXIS_GENERIC_10.

Value: 41

AXIS_GENERIC_11

static val AXIS_GENERIC_11: Int

Synonym for MotionEvent#AXIS_GENERIC_11.

Value: 42

AXIS_GENERIC_12

static val AXIS_GENERIC_12: Int

Synonym for MotionEvent#AXIS_GENERIC_12.

Value: 43

AXIS_GENERIC_13

static val AXIS_GENERIC_13: Int

Synonym for MotionEvent#AXIS_GENERIC_13.

Value: 44

AXIS_GENERIC_14

static val AXIS_GENERIC_14: Int

Synonym for MotionEvent#AXIS_GENERIC_14.

Value: 45

AXIS_GENERIC_15

static val AXIS_GENERIC_15: Int

Synonym for MotionEvent#AXIS_GENERIC_15.

Value: 46

AXIS_GENERIC_16

static val AXIS_GENERIC_16: Int

Synonym for MotionEvent#AXIS_GENERIC_16.

Value: 47

AXIS_GENERIC_2

static val AXIS_GENERIC_2: Int

Synonym for MotionEvent#AXIS_GENERIC_2.

Value: 33

AXIS_GENERIC_3

static val AXIS_GENERIC_3: Int

Synonym for MotionEvent#AXIS_GENERIC_3.

Value: 34

AXIS_GENERIC_4

static val AXIS_GENERIC_4: Int

Synonym for MotionEvent#AXIS_GENERIC_4.

Value: 35

AXIS_GENERIC_5

static val AXIS_GENERIC_5: Int

Synonym for MotionEvent#AXIS_GENERIC_5.

Value: 36

AXIS_GENERIC_6

static val AXIS_GENERIC_6: Int

Synonym for MotionEvent#AXIS_GENERIC_6.

Value: 37

AXIS_GENERIC_7

static val AXIS_GENERIC_7: Int

Synonym for MotionEvent#AXIS_GENERIC_7.

Value: 38

AXIS_GENERIC_8

static val AXIS_GENERIC_8: Int

Synonym for MotionEvent#AXIS_GENERIC_8.

Value: 39

AXIS_GENERIC_9

static val AXIS_GENERIC_9: Int

Synonym for MotionEvent#AXIS_GENERIC_9.

Value: 40

AXIS_HAT_X

static val AXIS_HAT_X: Int

Synonym for MotionEvent#AXIS_HAT_X.

Value: 15

AXIS_HAT_Y

static val AXIS_HAT_Y: Int

Synonym for MotionEvent#AXIS_HAT_Y.

Value: 16

AXIS_HSCROLL

static val AXIS_HSCROLL: Int

Synonym for MotionEvent#AXIS_HSCROLL.

Value: 10

AXIS_LTRIGGER

static val AXIS_LTRIGGER: Int

Synonym for MotionEvent#AXIS_LTRIGGER.

Value: 17

AXIS_ORIENTATION

static val AXIS_ORIENTATION: Int

Synonym for MotionEvent#AXIS_ORIENTATION.

Value: 8

AXIS_PRESSURE

static val AXIS_PRESSURE: Int

Synonym for MotionEvent#AXIS_PRESSURE.

Value: 2

AXIS_RELATIVE_X

static val AXIS_RELATIVE_X: Int

Synonym for MotionEvent#AXIS_RELATIVE_X.

Value: 27

AXIS_RELATIVE_Y

static val AXIS_RELATIVE_Y: Int

Synonym for MotionEvent#AXIS_RELATIVE_Y.

Value: 28

AXIS_RTRIGGER

static val AXIS_RTRIGGER: Int

Synonym for MotionEvent#AXIS_RTRIGGER.

Value: 18

AXIS_RUDDER

static val AXIS_RUDDER: Int

Synonym for MotionEvent#AXIS_RUDDER.

Value: 20

AXIS_RX

static val AXIS_RX: Int

Synonym for MotionEvent#AXIS_RX.

Value: 12

AXIS_RY

static val AXIS_RY: Int

Synonym for MotionEvent#AXIS_RY.

Value: 13

AXIS_RZ

static val AXIS_RZ: Int

Synonym for MotionEvent#AXIS_RZ.

Value: 14

AXIS_SCROLL

static val AXIS_SCROLL: Int

Synonym for MotionEvent#AXIS_SCROLL.

Value: 26

AXIS_SIZE

static val AXIS_SIZE: Int

Synonym for MotionEvent#AXIS_SIZE.

Value: 3

AXIS_THROTTLE

static val AXIS_THROTTLE: Int

Synonym for MotionEvent#AXIS_THROTTLE.

Value: 19

AXIS_TILT

static val AXIS_TILT: Int

Synonym for MotionEvent#AXIS_TILT.

Value: 25

AXIS_TOOL_MAJOR

static val AXIS_TOOL_MAJOR: Int

Synonym for MotionEvent#AXIS_TOOL_MAJOR.

Value: 6

AXIS_TOOL_MINOR

static val AXIS_TOOL_MINOR: Int

Synonym for MotionEvent#AXIS_TOOL_MINOR.

Value: 7

AXIS_TOUCH_MAJOR

static val AXIS_TOUCH_MAJOR: Int

Synonym for MotionEvent#AXIS_TOUCH_MAJOR.

Value: 4

AXIS_TOUCH_MINOR

static val AXIS_TOUCH_MINOR: Int

Synonym for MotionEvent#AXIS_TOUCH_MINOR.

Value: 5

AXIS_VSCROLL

static val AXIS_VSCROLL: Int

Synonym for MotionEvent#AXIS_VSCROLL.

Value: 9

AXIS_WHEEL

static val AXIS_WHEEL: Int

Synonym for MotionEvent#AXIS_WHEEL.

Value: 21

AXIS_X

static val AXIS_X: Int

Synonym for MotionEvent#AXIS_X.

Value: 0

AXIS_Y

static val AXIS_Y: Int

Synonym for MotionEvent#AXIS_Y.

Value: 1

AXIS_Z

static val AXIS_Z: Int

Synonym for MotionEvent#AXIS_Z.

Value: 11

BUTTON_PRIMARY

static val BUTTON_PRIMARY: Int

Synonym for MotionEvent#BUTTON_PRIMARY.

Value: 1

Public methods

findPointerIndex

static fun findPointerIndex(event: MotionEvent!, pointerId: Int): Int

Call MotionEvent#findPointerIndex(int).

getActionIndex

static fun getActionIndex(event: MotionEvent!): Int

Call MotionEvent#getAction, returning only the pointer index portion.

getActionMasked

static fun getActionMasked(event: MotionEvent!): Int

Call MotionEvent#getAction, returning only the ACTION_MASK portion.

getAxisValue

static fun getAxisValue(event: MotionEvent!, axis: Int): Float

Get axis value for the first pointer index (may be an arbitrary pointer identifier).

Parameters
axis MotionEvent!: The axis identifier for the axis value to retrieve.

See Also

getAxisValue

static fun getAxisValue(event: MotionEvent!, axis: Int, pointerIndex: Int): Float

Returns the value of the requested axis for the given pointer index (use getPointerId(MotionEvent, int) to find the pointer identifier for this index).

Parameters
axis MotionEvent!: The axis identifier for the axis value to retrieve.
pointerIndex MotionEvent!: Raw index of pointer to retrieve. Value may be from 0 (the first pointer that is down) to getPointerCount(MotionEvent)-1.
Return
Float: The value of the axis, or 0 if the axis is not available.

See Also

getButtonState

static fun getButtonState(event: MotionEvent!): Int

getPointerCount

static fun getPointerCount(event: MotionEvent!): Int

The number of pointers of data contained in this event. Always

getPointerId

static fun getPointerId(event: MotionEvent!, pointerIndex: Int): Int

Call MotionEvent#getPointerId(int).

getSource

static fun getSource(event: MotionEvent!): Int

Gets the source of the event.

Return
Int: The event source or InputDeviceCompat#SOURCE_UNKNOWN if unknown.

getX

static fun getX(event: MotionEvent!, pointerIndex: Int): Float

Call MotionEvent#getX(int).

getY

static fun getY(event: MotionEvent!, pointerIndex: Int): Float

Call MotionEvent#getY(int).

isFromSource

static fun isFromSource(event: MotionEvent!, source: Int): Boolean

Determines whether the event is from the given source.

Parameters
source MotionEvent!: The input source to check against.
Return
Boolean: Whether the event is from the given source.