Java android.view MotionEvent fields, constructors, methods, implement or subclass

Example usage for Java android.view MotionEvent fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for android.view MotionEvent.

The text is from its open source code.

Field

intINVALID_POINTER_ID
An invalid pointer id.
intACTION_MASK
Bit mask of the parts of the action code that are the action itself.
intACTION_DOWN
Constant for #getActionMasked : A pressed gesture has started, the motion contains the initial starting location.
intACTION_UP
Constant for #getActionMasked : A pressed gesture has finished, the motion contains the final release location as well as any intermediate points since the last down or move event.
intACTION_MOVE
Constant for #getActionMasked : A change has happened during a press gesture (between #ACTION_DOWN and #ACTION_UP ).
intACTION_CANCEL
Constant for #getActionMasked : The current gesture has been aborted.
intACTION_OUTSIDE
Constant for #getActionMasked : A movement has happened outside of the normal bounds of the UI element.
intACTION_POINTER_DOWN
Constant for #getActionMasked : A non-primary pointer has gone down.
intACTION_POINTER_UP
Constant for #getActionMasked : A non-primary pointer has gone up.
intACTION_HOVER_MOVE
Constant for #getActionMasked : A change happened but the pointer is not down (unlike #ACTION_MOVE ).
intACTION_SCROLL
Constant for #getActionMasked : The motion event contains relative vertical and/or horizontal scroll offsets.
intACTION_HOVER_ENTER
Constant for #getActionMasked : The pointer is not down but has entered the boundaries of a window or view.
intACTION_HOVER_EXIT
Constant for #getActionMasked : The pointer is not down but has exited the boundaries of a window or view.
intACTION_BUTTON_PRESS
Constant for #getActionMasked : A button has been pressed.
intACTION_POINTER_INDEX_MASK
Bits in the action code that represent a pointer index, used with #ACTION_POINTER_DOWN and #ACTION_POINTER_UP .
intACTION_POINTER_INDEX_SHIFT
Bit shift for the action bits holding the pointer index as defined by #ACTION_POINTER_INDEX_MASK .
intACTION_POINTER_1_DOWN
intACTION_POINTER_2_DOWN
intACTION_POINTER_1_UP
intACTION_POINTER_2_UP
intACTION_POINTER_3_UP
intACTION_POINTER_ID_MASK
intACTION_POINTER_ID_SHIFT
intAXIS_X
Axis constant: X axis of a motion event.
intAXIS_Y
Axis constant: Y axis of a motion event.
intAXIS_VSCROLL
Axis constant: Vertical Scroll axis of a motion event.
intAXIS_HSCROLL
Axis constant: Horizontal Scroll axis of a motion event.
intAXIS_Z
Axis constant: Z axis of a motion event.
intAXIS_RX
Axis constant: X Rotation axis of a motion event.
intAXIS_RY
Axis constant: Y Rotation axis of a motion event.
intAXIS_RZ
Axis constant: Z Rotation axis of a motion event.
intAXIS_HAT_X
Axis constant: Hat X axis of a motion event.
intAXIS_HAT_Y
Axis constant: Hat Y axis of a motion event.
intAXIS_LTRIGGER
Axis constant: Left Trigger axis of a motion event.
intAXIS_RTRIGGER
Axis constant: Right Trigger axis of a motion event.
intAXIS_GAS
Axis constant: Gas axis of a motion event.
intAXIS_BRAKE
Axis constant: Brake axis of a motion event.
intBUTTON_PRIMARY
Button constant: Primary button (left mouse button).
intBUTTON_SECONDARY
Button constant: Secondary button (right mouse button).
intBUTTON_TERTIARY
Button constant: Tertiary button (middle mouse button).
intBUTTON_STYLUS_PRIMARY
Button constant: Primary stylus button pressed.
intBUTTON_STYLUS_SECONDARY
Button constant: Secondary stylus button pressed.
intTOOL_TYPE_FINGER
Tool type constant: The tool is a finger.
intTOOL_TYPE_STYLUS
Tool type constant: The tool is a stylus.
intTOOL_TYPE_MOUSE
Tool type constant: The tool is a mouse or trackpad.

Method

StringactionToString(int action)
Returns a string that represents the symbolic name of the specified unmasked action such as "ACTION_DOWN", "ACTION_POINTER_DOWN(3)" or an equivalent numeric constant such as "35" if unknown.
StringaxisToString(int axis)
Returns a string that represents the symbolic name of the specified axis such as "AXIS_X" or an equivalent numeric constant such as "42" if unknown.
booleanequals(Object obj)
Indicates whether some other object is "equal to" this one.
intfindPointerIndex(int pointerId)
Given a pointer identifier, find the index of its data in the event.
intgetAction()
Return the kind of action being performed.
intgetActionIndex()
For #ACTION_POINTER_DOWN or #ACTION_POINTER_UP as returned by #getActionMasked , this returns the associated pointer index.
intgetActionMasked()
Return the masked action being performed, without pointer index information.
floatgetAxisValue(int axis)
#getAxisValue(int) for the first pointer index (may be an arbitrary pointer identifier).
intgetButtonState()
Gets the state of all buttons that are pressed such as a mouse or stylus button.
ClassgetClass()
Returns the runtime class of this Object .
InputDevicegetDevice()
Gets the device that this event came from.
intgetDeviceId()
longgetDownTime()
Returns the time (in ms) when the user originally pressed down to start a stream of position events.
intgetEdgeFlags()
Returns a bitfield indicating which edges, if any, were touched by this MotionEvent.
longgetEventTime()
Retrieve the time this event occurred, in the android.os.SystemClock#uptimeMillis time base.
intgetFlags()
Gets the motion event flags.
floatgetHistoricalAxisValue(int axis, int pos)
#getHistoricalAxisValue(int,int,int) for the first pointer index (may be an arbitrary pointer identifier).
longgetHistoricalEventTime(int pos)
Returns the time that a historical movement occurred between this event and the previous event, in the android.os.SystemClock#uptimeMillis time base.
floatgetHistoricalPressure(int pointerIndex, int pos)
Returns a historical pressure coordinate, as per #getPressure(int) , that occurred between this event and the previous event for the given pointer.
floatgetHistoricalPressure(int pos)
#getHistoricalPressure(int,int) for the first pointer index (may be an arbitrary pointer identifier).
floatgetHistoricalSize(int pointerIndex, int pos)
Returns a historical size coordinate, as per #getSize(int) , that occurred between this event and the previous event for the given pointer.
floatgetHistoricalSize(int pos)
#getHistoricalSize(int,int) for the first pointer index (may be an arbitrary pointer identifier).
floatgetHistoricalX(int pos)
#getHistoricalX(int,int) for the first pointer index (may be an arbitrary pointer identifier).
floatgetHistoricalX(int pointerIndex, int pos)
Returns a historical X coordinate, as per #getX(int) , that occurred between this event and the previous event for the given pointer.
floatgetHistoricalY(int pos)
#getHistoricalY(int,int) for the first pointer index (may be an arbitrary pointer identifier).
floatgetHistoricalY(int pointerIndex, int pos)
Returns a historical Y coordinate, as per #getY(int) , that occurred between this event and the previous event for the given pointer.
intgetHistorySize()
Returns the number of historical points in this event.
intgetMetaState()
Returns the state of any meta / modifier keys that were in effect when the event was generated.
floatgetOrientation(int pointerIndex)
Returns the orientation of the touch area and tool area in radians clockwise from vertical for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
voidgetPointerCoords(int pointerIndex, PointerCoords outPointerCoords)
Populates a PointerCoords object with pointer coordinate data for the specified pointer index.
intgetPointerCount()
The number of pointers of data contained in this event.
intgetPointerId(int pointerIndex)
Return the pointer identifier associated with a particular pointer data index in this event.
voidgetPointerProperties(int pointerIndex, PointerProperties outPointerProperties)
Populates a PointerProperties object with pointer properties for the specified pointer index.
floatgetPressure(int pointerIndex)
Returns the current pressure of this event for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
floatgetPressure()
#getPressure(int) for the first pointer index (may be an arbitrary pointer identifier).
floatgetRawX()
Returns the original raw X coordinate of this event.
floatgetRawY()
Returns the original raw Y coordinate of this event.
floatgetSize(int pointerIndex)
Returns a scaled value of the approximate size for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
floatgetSize()
#getSize(int) for the first pointer index (may be an arbitrary pointer identifier).
intgetSource()
floatgetToolMajor(int pointerIndex)
Returns the length of the major axis of an ellipse that describes the size of the approaching tool for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
floatgetToolMinor(int pointerIndex)
Returns the length of the minor axis of an ellipse that describes the size of the approaching tool for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
intgetToolType(int pointerIndex)
Gets the tool type of a pointer for the given pointer index.
floatgetTouchMajor(int pointerIndex)
Returns the length of the major axis of an ellipse that describes the touch area at the point of contact for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
floatgetTouchMinor(int pointerIndex)
Returns the length of the minor axis of an ellipse that describes the touch area at the point of contact for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
floatgetX(int pointerIndex)
Returns the X coordinate of this event for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
floatgetX()
#getX(int) for the first pointer index (may be an arbitrary pointer identifier).
floatgetXPrecision()
Return the precision of the X coordinates being reported.
floatgetY(int pointerIndex)
Returns the Y coordinate of this event for the given pointer index (use #getPointerId(int) to find the pointer identifier for this index).
floatgetY()
#getY(int) for the first pointer index (may be an arbitrary pointer identifier).
floatgetYPrecision()
Return the precision of the Y coordinates being reported.
booleanisButtonPressed(int button)
Checks if a mouse or stylus button (or combination of buttons) is pressed.
MotionEventobtain(long downTime, long eventTime, int action, float x, float y, int metaState)
Create a new MotionEvent, filling in a subset of the basic motion values.
MotionEventobtain(long downTime, long eventTime, int action, int pointerCount, int[] pointerIds, PointerCoords[] pointerCoords, int metaState, float xPrecision, float yPrecision, int deviceId, int edgeFlags, int source, int flags)
Create a new MotionEvent, filling in all of the basic values that define the motion.
MotionEventobtain(long downTime, long eventTime, int action, int pointerCount, float x, float y, float pressure, float size, int metaState, float xPrecision, float yPrecision, int deviceId, int edgeFlags)
Create a new MotionEvent, filling in all of the basic values that define the motion.
MotionEventobtain(MotionEvent other)
Create a new MotionEvent, copying from an existing one.
MotionEventobtain(long downTime, long eventTime, int action, int pointerCount, PointerProperties[] pointerProperties, PointerCoords[] pointerCoords, int metaState, int buttonState, float xPrecision, float yPrecision, int deviceId, int edgeFlags, int source, int flags)
Create a new MotionEvent, filling in all of the basic values that define the motion.
MotionEventobtainNoHistory(MotionEvent other)
Create a new MotionEvent, copying from an existing one, but not including any historical point information.
voidoffsetLocation(float deltaX, float deltaY)
Adjust this event's location.
voidrecycle()
Recycle the MotionEvent, to be re-used by a later caller.
voidsetAction(int action)
Sets this event's action.
voidsetLocation(float x, float y)
Set this event's location.
voidsetSource(int source)
StringtoString()
voidtransform(Matrix matrix)
Applies a transformation matrix to all of the points in the event.