Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

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

Deprecated: Use MotionEvent#ACTION_HOVER_ENTER directly.

Synonym for MotionEvent#ACTION_HOVER_ENTER.

Value: 9

ACTION_HOVER_EXIT

static val ACTION_HOVER_EXIT: Int

Deprecated: Use MotionEvent#ACTION_HOVER_EXIT directly.

Synonym for MotionEvent#ACTION_HOVER_EXIT.

Value: 10

ACTION_HOVER_MOVE

static val ACTION_HOVER_MOVE: Int

Deprecated: Use MotionEvent#ACTION_HOVER_MOVE directly.

Synonym for MotionEvent#ACTION_HOVER_MOVE.

Value: 7

ACTION_MASK

static val ACTION_MASK: Int

Deprecated: Use MotionEvent#ACTION_MASK directly.

Synonym for MotionEvent#ACTION_MASK.

Value: 0xff

ACTION_POINTER_DOWN

static val ACTION_POINTER_DOWN: Int

Deprecated: Use MotionEvent#ACTION_POINTER_DOWN directly.

Synonym for MotionEvent#ACTION_POINTER_DOWN.

Value: 5

ACTION_POINTER_INDEX_MASK

static val ACTION_POINTER_INDEX_MASK: Int

Deprecated: Use MotionEvent#ACTION_POINTER_INDEX_MASK directly.

Synonym for MotionEvent#ACTION_POINTER_INDEX_MASK.

Value: 0xff00

ACTION_POINTER_INDEX_SHIFT

static val ACTION_POINTER_INDEX_SHIFT: Int

Deprecated: Use MotionEvent#ACTION_POINTER_INDEX_SHIFT directly.

Synonym for MotionEvent#ACTION_POINTER_INDEX_SHIFT.

Value: 8

ACTION_POINTER_UP

static val ACTION_POINTER_UP: Int

Deprecated: Use MotionEvent#ACTION_POINTER_UP directly.

Synonym for MotionEvent#ACTION_POINTER_UP.

Value: 6

ACTION_SCROLL

static val ACTION_SCROLL: Int

Deprecated: Use MotionEvent#ACTION_SCROLL directly.

Synonym for MotionEvent#ACTION_SCROLL.

Value: 8

AXIS_BRAKE

static val AXIS_BRAKE: Int

Deprecated: Use MotionEvent#AXIS_BRAKE directly.

Synonym for MotionEvent#AXIS_BRAKE.

Value: 23

AXIS_DISTANCE

static val AXIS_DISTANCE: Int

Deprecated: Use MotionEvent#AXIS_DISTANCE directly.

Synonym for MotionEvent#AXIS_DISTANCE.

Value: 24

AXIS_GAS

static val AXIS_GAS: Int

Deprecated: Use MotionEvent#AXIS_GAS directly.

Synonym for MotionEvent#AXIS_GAS.

Value: 22

AXIS_GENERIC_1

static val AXIS_GENERIC_1: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_1 directly.

Synonym for MotionEvent#AXIS_GENERIC_1.

Value: 32

AXIS_GENERIC_10

static val AXIS_GENERIC_10: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_10 directly.

Synonym for MotionEvent#AXIS_GENERIC_10.

Value: 41

AXIS_GENERIC_11

static val AXIS_GENERIC_11: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_11 directly.

Synonym for MotionEvent#AXIS_GENERIC_11.

Value: 42

AXIS_GENERIC_12

static val AXIS_GENERIC_12: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_12 directly.

Synonym for MotionEvent#AXIS_GENERIC_12.

Value: 43

AXIS_GENERIC_13

static val AXIS_GENERIC_13: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_13 directly.

Synonym for MotionEvent#AXIS_GENERIC_13.

Value: 44

AXIS_GENERIC_14

static val AXIS_GENERIC_14: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_14 directly.

Synonym for MotionEvent#AXIS_GENERIC_14.

Value: 45

AXIS_GENERIC_15

static val AXIS_GENERIC_15: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_15 directly.

Synonym for MotionEvent#AXIS_GENERIC_15.

Value: 46

AXIS_GENERIC_16

static val AXIS_GENERIC_16: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_16 directly.

Synonym for MotionEvent#AXIS_GENERIC_16.

Value: 47

AXIS_GENERIC_2

static val AXIS_GENERIC_2: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_2 directly.

Synonym for MotionEvent#AXIS_GENERIC_2.

Value: 33

AXIS_GENERIC_3

static val AXIS_GENERIC_3: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_3 directly.

Synonym for MotionEvent#AXIS_GENERIC_3.

Value: 34

AXIS_GENERIC_4

static val AXIS_GENERIC_4: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_4 directly.

Synonym for MotionEvent#AXIS_GENERIC_4.

Value: 35

AXIS_GENERIC_5

static val AXIS_GENERIC_5: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_5 directly.

Synonym for MotionEvent#AXIS_GENERIC_5.

Value: 36

AXIS_GENERIC_6

static val AXIS_GENERIC_6: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_6 directly.

Synonym for MotionEvent#AXIS_GENERIC_6.

Value: 37

AXIS_GENERIC_7

static val AXIS_GENERIC_7: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_7 directly.

Synonym for MotionEvent#AXIS_GENERIC_7.

Value: 38

AXIS_GENERIC_8

static val AXIS_GENERIC_8: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_8 directly.

Synonym for MotionEvent#AXIS_GENERIC_8.

Value: 39

AXIS_GENERIC_9

static val AXIS_GENERIC_9: Int

Deprecated: Use MotionEvent#AXIS_GENERIC_9 directly.

Synonym for MotionEvent#AXIS_GENERIC_9.

Value: 40

AXIS_HAT_X

static val AXIS_HAT_X: Int

Deprecated: Use MotionEvent#AXIS_HAT_X directly.

Synonym for MotionEvent#AXIS_HAT_X.

Value: 15

AXIS_HAT_Y

static val AXIS_HAT_Y: Int

Deprecated: Use MotionEvent#AXIS_HAT_Y directly.

Synonym for MotionEvent#AXIS_HAT_Y.

Value: 16

AXIS_HSCROLL

static val AXIS_HSCROLL: Int

Deprecated: Use MotionEvent#AXIS_HSCROLL directly.

Synonym for MotionEvent#AXIS_HSCROLL.

Value: 10

AXIS_LTRIGGER

static val AXIS_LTRIGGER: Int

Deprecated: Use MotionEvent#AXIS_LTRIGGER directly.

Synonym for MotionEvent#AXIS_LTRIGGER.

Value: 17

AXIS_ORIENTATION

static val AXIS_ORIENTATION: Int

Deprecated: Use MotionEvent#AXIS_ORIENTATION directly.

Synonym for MotionEvent#AXIS_ORIENTATION.

Value: 8

AXIS_PRESSURE

static val AXIS_PRESSURE: Int

Deprecated: Use MotionEvent#AXIS_PRESSURE directly.

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

Deprecated: Use MotionEvent#AXIS_RTRIGGER directly.

Synonym for MotionEvent#AXIS_RTRIGGER.

Value: 18

AXIS_RUDDER

static val AXIS_RUDDER: Int

Deprecated: Use MotionEvent#AXIS_RUDDER directly.

Synonym for MotionEvent#AXIS_RUDDER.

Value: 20

AXIS_RX

static val AXIS_RX: Int

Deprecated: Use MotionEvent#AXIS_RX directly.

Synonym for MotionEvent#AXIS_RX.

Value: 12

AXIS_RY

static val AXIS_RY: Int

Deprecated: Use MotionEvent#AXIS_RY directly.

Synonym for MotionEvent#AXIS_RY.

Value: 13

AXIS_RZ

static val AXIS_RZ: Int

Deprecated: Use MotionEvent#AXIS_RZ directly.

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

Deprecated: Use MotionEvent#AXIS_SIZE directly.

Synonym for MotionEvent#AXIS_SIZE.

Value: 3

AXIS_THROTTLE

static val AXIS_THROTTLE: Int

Deprecated: Use MotionEvent#AXIS_THROTTLE directly.

Synonym for MotionEvent#AXIS_THROTTLE.

Value: 19

AXIS_TILT

static val AXIS_TILT: Int

Deprecated: Use MotionEvent#AXIS_TILT directly.

Synonym for MotionEvent#AXIS_TILT.

Value: 25

AXIS_TOOL_MAJOR

static val AXIS_TOOL_MAJOR: Int

Deprecated: Use MotionEvent#AXIS_TOOL_MAJOR directly.

Synonym for MotionEvent#AXIS_TOOL_MAJOR.

Value: 6

AXIS_TOOL_MINOR

static val AXIS_TOOL_MINOR: Int

Deprecated: Use MotionEvent#AXIS_TOOL_MINOR directly.

Synonym for MotionEvent#AXIS_TOOL_MINOR.

Value: 7

AXIS_TOUCH_MAJOR

static val AXIS_TOUCH_MAJOR: Int

Deprecated: Use MotionEvent#AXIS_TOUCH_MAJOR directly.

Synonym for MotionEvent#AXIS_TOUCH_MAJOR.

Value: 4

AXIS_TOUCH_MINOR

static val AXIS_TOUCH_MINOR: Int

Deprecated: Use MotionEvent#AXIS_TOUCH_MINOR directly.

Synonym for MotionEvent#AXIS_TOUCH_MINOR.

Value: 5

AXIS_VSCROLL

static val AXIS_VSCROLL: Int

Deprecated: Use MotionEvent#AXIS_VSCROLL directly.

Synonym for MotionEvent#AXIS_VSCROLL.

Value: 9

AXIS_WHEEL

static val AXIS_WHEEL: Int

Deprecated: Use MotionEvent#AXIS_WHEEL directly.

Synonym for MotionEvent#AXIS_WHEEL.

Value: 21

AXIS_X

static val AXIS_X: Int

Deprecated: Use MotionEvent#AXIS_X directly.

Synonym for MotionEvent#AXIS_X.

Value: 0

AXIS_Y

static val AXIS_Y: Int

Deprecated: Use MotionEvent#AXIS_Y directly.

Synonym for MotionEvent#AXIS_Y.

Value: 1

AXIS_Z

static val AXIS_Z: Int

Deprecated: Use MotionEvent#AXIS_Z directly.

Synonym for MotionEvent#AXIS_Z.

Value: 11

BUTTON_PRIMARY

static val BUTTON_PRIMARY: Int

Deprecated: Use MotionEvent#BUTTON_PRIMARY directly.

Synonym for MotionEvent#BUTTON_PRIMARY.

Value: 1

Public methods

findPointerIndex

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

Deprecated: Call MotionEvent#findPointerIndex(int) directly. This method will be removed in a future release.

Call MotionEvent#findPointerIndex(int).

getActionIndex

static fun getActionIndex(event: MotionEvent!): Int

Deprecated: Call MotionEvent#getActionIndex() directly. This method will be removed in a future release.

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

getActionMasked

static fun getActionMasked(event: MotionEvent!): Int

Deprecated: Call MotionEvent#getAction() directly. This method will be removed in a future release.

Call MotionEvent#getAction, returning only the ACTION_MASK portion.

getAxisValue

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

Deprecated: Call MotionEvent#getAxisValue(int) directly. This method will be removed in a future release.

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

Deprecated: Call MotionEvent#getAxisValue(int, int) directly. This method will be removed in a future release.

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

Deprecated: Call MotionEvent#getButtonState() directly. This method will be removed in a future release.

getPointerCount

static fun getPointerCount(event: MotionEvent!): Int

Deprecated: Call MotionEvent#getPointerCount() directly. This method will be removed in a future release.

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

getPointerId

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

Deprecated: Call MotionEvent#getPointerId(int) directly. This method will be removed in a future release.

Call MotionEvent#getPointerId(int).

getSource

static fun getSource(event: MotionEvent!): Int

Deprecated: Call MotionEvent#getSource() directly. This method will be removed in a future release.

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

Deprecated: Call MotionEvent#getX() directly. This method will be removed in a future release.

Call MotionEvent#getX(int).

getY

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

Deprecated: Call MotionEvent#getY() directly. This method will be removed in a future release.

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.