Android APIs
public class

MotionEventCompat

extends Object
java.lang.Object
   ↳ android.support.v4.view.MotionEventCompat

Class Overview

Helper for accessing features in MotionEvent introduced after API level 4 in a backwards compatible fashion.

Summary

Constants
int ACTION_HOVER_ENTER Synonym for ACTION_HOVER_ENTER.
int ACTION_HOVER_EXIT Synonym for ACTION_HOVER_EXIT.
int ACTION_HOVER_MOVE Synonym for ACTION_HOVER_MOVE.
int ACTION_MASK Synonym for ACTION_MASK.
int ACTION_POINTER_DOWN Synonym for ACTION_POINTER_DOWN.
int ACTION_POINTER_INDEX_MASK Synonym for ACTION_POINTER_INDEX_MASK.
int ACTION_POINTER_INDEX_SHIFT Synonym for ACTION_POINTER_INDEX_SHIFT.
int ACTION_POINTER_UP Synonym for ACTION_POINTER_UP.
int ACTION_SCROLL Synonym for ACTION_SCROLL.
int AXIS_BRAKE Synonym for AXIS_BRAKE.
int AXIS_DISTANCE Synonym for AXIS_DISTANCE.
int AXIS_GAS Synonym for AXIS_GAS.
int AXIS_GENERIC_1 Synonym for AXIS_GENERIC_1.
int AXIS_GENERIC_10 Synonym for AXIS_GENERIC_10.
int AXIS_GENERIC_11 Synonym for AXIS_GENERIC_11.
int AXIS_GENERIC_12 Synonym for AXIS_GENERIC_12.
int AXIS_GENERIC_13 Synonym for AXIS_GENERIC_13.
int AXIS_GENERIC_14 Synonym for AXIS_GENERIC_14.
int AXIS_GENERIC_15 Synonym for AXIS_GENERIC_15.
int AXIS_GENERIC_16 Synonym for AXIS_GENERIC_16.
int AXIS_GENERIC_2 Synonym for AXIS_GENERIC_2.
int AXIS_GENERIC_3 Synonym for AXIS_GENERIC_3.
int AXIS_GENERIC_4 Synonym for AXIS_GENERIC_4.
int AXIS_GENERIC_5 Synonym for AXIS_GENERIC_5.
int AXIS_GENERIC_6 Synonym for AXIS_GENERIC_6.
int AXIS_GENERIC_7 Synonym for AXIS_GENERIC_7.
int AXIS_GENERIC_8 Synonym for AXIS_GENERIC_8.
int AXIS_GENERIC_9 Synonym for AXIS_GENERIC_9.
int AXIS_HAT_X Synonym for AXIS_HAT_X.
int AXIS_HAT_Y Synonym for AXIS_HAT_Y.
int AXIS_HSCROLL Synonym for AXIS_HSCROLL.
int AXIS_LTRIGGER Synonym for AXIS_LTRIGGER.
int AXIS_ORIENTATION Synonym for AXIS_ORIENTATION.
int AXIS_PRESSURE Synonym for AXIS_PRESSURE.
int AXIS_RTRIGGER Synonym for AXIS_RTRIGGER.
int AXIS_RUDDER Synonym for AXIS_RUDDER.
int AXIS_RX Synonym for AXIS_RX.
int AXIS_RY Synonym for AXIS_RY.
int AXIS_RZ Synonym for AXIS_RZ.
int AXIS_SIZE Synonym for AXIS_SIZE.
int AXIS_THROTTLE Synonym for AXIS_THROTTLE.
int AXIS_TILT Synonym for AXIS_TILT.
int AXIS_TOOL_MAJOR Synonym for AXIS_TOOL_MAJOR.
int AXIS_TOOL_MINOR Synonym for AXIS_TOOL_MINOR.
int AXIS_TOUCH_MAJOR Synonym for AXIS_TOUCH_MAJOR.
int AXIS_TOUCH_MINOR Synonym for AXIS_TOUCH_MINOR.
int AXIS_VSCROLL Synonym for AXIS_VSCROLL.
int AXIS_WHEEL Synonym for AXIS_WHEEL.
int AXIS_X Synonym for AXIS_X.
int AXIS_Y Synonym for AXIS_Y.
int AXIS_Z Synonym for AXIS_Z.
Public Constructors
MotionEventCompat()
Public Methods
static int findPointerIndex(MotionEvent event, int pointerId)
static int getActionIndex(MotionEvent event)
Call getAction(), returning only the pointer index portion
static int getActionMasked(MotionEvent event)
Call getAction(), returning only the ACTION_MASK portion.
static float getAxisValue(MotionEvent event, int axis, int pointerIndex)
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 float getAxisValue(MotionEvent event, int axis)
Get axis value for the first pointer index (may be an arbitrary pointer identifier).
static int getPointerCount(MotionEvent event)
The number of pointers of data contained in this event.
static int getPointerId(MotionEvent event, int pointerIndex)
static int getSource(MotionEvent event)
Gets the source of the event.
static float getX(MotionEvent event, int pointerIndex)
Call getX(int).
static float getY(MotionEvent event, int pointerIndex)
Call getY(int).
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ACTION_HOVER_ENTER

Synonym for ACTION_HOVER_ENTER.

Constant Value: 9 (0x00000009)

public static final int ACTION_HOVER_EXIT

Synonym for ACTION_HOVER_EXIT.

Constant Value: 10 (0x0000000a)

public static final int ACTION_HOVER_MOVE

Synonym for ACTION_HOVER_MOVE.

Constant Value: 7 (0x00000007)

public static final int ACTION_MASK

Synonym for ACTION_MASK.

Constant Value: 255 (0x000000ff)

public static final int ACTION_POINTER_DOWN

Synonym for ACTION_POINTER_DOWN.

Constant Value: 5 (0x00000005)

public static final int ACTION_POINTER_INDEX_MASK

Synonym for ACTION_POINTER_INDEX_MASK.

Constant Value: 65280 (0x0000ff00)

public static final int ACTION_POINTER_INDEX_SHIFT

Synonym for ACTION_POINTER_INDEX_SHIFT.

Constant Value: 8 (0x00000008)

public static final int ACTION_POINTER_UP

Synonym for ACTION_POINTER_UP.

Constant Value: 6 (0x00000006)

public static final int ACTION_SCROLL

Synonym for ACTION_SCROLL.

Constant Value: 8 (0x00000008)

public static final int AXIS_BRAKE

Synonym for AXIS_BRAKE.

Constant Value: 23 (0x00000017)

public static final int AXIS_DISTANCE

Synonym for AXIS_DISTANCE.

Constant Value: 24 (0x00000018)

public static final int AXIS_GAS

Synonym for AXIS_GAS.

Constant Value: 22 (0x00000016)

public static final int AXIS_GENERIC_1

Synonym for AXIS_GENERIC_1.

Constant Value: 32 (0x00000020)

public static final int AXIS_GENERIC_10

Synonym for AXIS_GENERIC_10.

Constant Value: 41 (0x00000029)

public static final int AXIS_GENERIC_11

Synonym for AXIS_GENERIC_11.

Constant Value: 42 (0x0000002a)

public static final int AXIS_GENERIC_12

Synonym for AXIS_GENERIC_12.

Constant Value: 43 (0x0000002b)

public static final int AXIS_GENERIC_13

Synonym for AXIS_GENERIC_13.

Constant Value: 44 (0x0000002c)

public static final int AXIS_GENERIC_14

Synonym for AXIS_GENERIC_14.

Constant Value: 45 (0x0000002d)

public static final int AXIS_GENERIC_15

Synonym for AXIS_GENERIC_15.

Constant Value: 46 (0x0000002e)

public static final int AXIS_GENERIC_16

Synonym for AXIS_GENERIC_16.

Constant Value: 47 (0x0000002f)

public static final int AXIS_GENERIC_2

Synonym for AXIS_GENERIC_2.

Constant Value: 33 (0x00000021)

public static final int AXIS_GENERIC_3

Synonym for AXIS_GENERIC_3.

Constant Value: 34 (0x00000022)

public static final int AXIS_GENERIC_4

Synonym for AXIS_GENERIC_4.

Constant Value: 35 (0x00000023)

public static final int AXIS_GENERIC_5

Synonym for AXIS_GENERIC_5.

Constant Value: 36 (0x00000024)

public static final int AXIS_GENERIC_6

Synonym for AXIS_GENERIC_6.

Constant Value: 37 (0x00000025)

public static final int AXIS_GENERIC_7

Synonym for AXIS_GENERIC_7.

Constant Value: 38 (0x00000026)

public static final int AXIS_GENERIC_8

Synonym for AXIS_GENERIC_8.

Constant Value: 39 (0x00000027)

public static final int AXIS_GENERIC_9

Synonym for AXIS_GENERIC_9.

Constant Value: 40 (0x00000028)

public static final int AXIS_HAT_X

Synonym for AXIS_HAT_X.

Constant Value: 15 (0x0000000f)

public static final int AXIS_HAT_Y

Synonym for AXIS_HAT_Y.

Constant Value: 16 (0x00000010)

public static final int AXIS_HSCROLL

Synonym for AXIS_HSCROLL.

Constant Value: 10 (0x0000000a)

public static final int AXIS_LTRIGGER

Synonym for AXIS_LTRIGGER.

Constant Value: 17 (0x00000011)

public static final int AXIS_ORIENTATION

Synonym for AXIS_ORIENTATION.

Constant Value: 8 (0x00000008)

public static final int AXIS_PRESSURE

Synonym for AXIS_PRESSURE.

Constant Value: 2 (0x00000002)

public static final int AXIS_RTRIGGER

Synonym for AXIS_RTRIGGER.

Constant Value: 18 (0x00000012)

public static final int AXIS_RUDDER

Synonym for AXIS_RUDDER.

Constant Value: 20 (0x00000014)

public static final int AXIS_RX

Synonym for AXIS_RX.

Constant Value: 12 (0x0000000c)

public static final int AXIS_RY

Synonym for AXIS_RY.

Constant Value: 13 (0x0000000d)

public static final int AXIS_RZ

Synonym for AXIS_RZ.

Constant Value: 14 (0x0000000e)

public static final int AXIS_SIZE

Synonym for AXIS_SIZE.

Constant Value: 3 (0x00000003)

public static final int AXIS_THROTTLE

Synonym for AXIS_THROTTLE.

Constant Value: 19 (0x00000013)

public static final int AXIS_TILT

Synonym for AXIS_TILT.

Constant Value: 25 (0x00000019)

public static final int AXIS_TOOL_MAJOR

Synonym for AXIS_TOOL_MAJOR.

Constant Value: 6 (0x00000006)

public static final int AXIS_TOOL_MINOR

Synonym for AXIS_TOOL_MINOR.

Constant Value: 7 (0x00000007)

public static final int AXIS_TOUCH_MAJOR

Synonym for AXIS_TOUCH_MAJOR.

Constant Value: 4 (0x00000004)

public static final int AXIS_TOUCH_MINOR

Synonym for AXIS_TOUCH_MINOR.

Constant Value: 5 (0x00000005)

public static final int AXIS_VSCROLL

Synonym for AXIS_VSCROLL.

Constant Value: 9 (0x00000009)

public static final int AXIS_WHEEL

Synonym for AXIS_WHEEL.

Constant Value: 21 (0x00000015)

public static final int AXIS_X

Synonym for AXIS_X.

Constant Value: 0 (0x00000000)

public static final int AXIS_Y

Synonym for AXIS_Y.

Constant Value: 1 (0x00000001)

public static final int AXIS_Z

Synonym for AXIS_Z.

Constant Value: 11 (0x0000000b)

Public Constructors

public MotionEventCompat ()

Public Methods

public static int findPointerIndex (MotionEvent event, int pointerId)

Call findPointerIndex(int). If running on a pre-ECLAIR device, does nothing and returns -1.

Parameters
event
pointerId
Returns
int

public static int getActionIndex (MotionEvent event)

Call getAction(), returning only the pointer index portion

Parameters
event
Returns
int

public static int getActionMasked (MotionEvent event)

Call getAction(), returning only the ACTION_MASK portion.

Parameters
event
Returns
int

public static float getAxisValue (MotionEvent event, int axis, int pointerIndex)

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 The axis identifier for the axis value to retrieve.
pointerIndex Raw index of pointer to retrieve. Value may be from 0 (the first pointer that is down) to getPointerCount(MotionEvent)-1.
Returns
float The value of the axis, or 0 if the axis is not available.

See also:

public static float getAxisValue (MotionEvent event, int axis)

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

Parameters
axis The axis identifier for the axis value to retrieve.
Returns
float

See also:

public static int getPointerCount (MotionEvent event)

The number of pointers of data contained in this event. Always >= 1.

Parameters
event
Returns
int

public static int getPointerId (MotionEvent event, int pointerIndex)

Call getPointerId(int). If running on a pre-ECLAIR device, IndexOutOfBoundsException is thrown.

Parameters
event
pointerIndex
Returns
int

public static int getSource (MotionEvent event)

Gets the source of the event.

Parameters
event
Returns
int The event source or SOURCE_UNKNOWN if unknown.

public static float getX (MotionEvent event, int pointerIndex)

Call getX(int). If running on a pre-ECLAIR device, IndexOutOfBoundsException is thrown.

Parameters
event
pointerIndex
Returns
float

public static float getY (MotionEvent event, int pointerIndex)

Call getY(int). If running on a pre-ECLAIR device, IndexOutOfBoundsException is thrown.

Parameters
event
pointerIndex
Returns
float