java.lang.Object | |
↳ | android.view.MotionEvent |
Object used to report movement (mouse, pen, finger, trackball) events. This class may hold either absolute or relative movements, depending on what it is being used for.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | ACTION_CANCEL | Constant for getAction(): The current gesture has been aborted. | |||||||||
int | ACTION_DOWN | Constant for getAction(): A pressed gesture has started, the motion contains the initial starting location. | |||||||||
int | ACTION_MOVE | Constant for getAction(): A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP). | |||||||||
int | ACTION_OUTSIDE | Constant for getAction(): A movement has happened outside of the normal bounds of the UI element. | |||||||||
int | ACTION_UP | Constant for getAction(): 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. | |||||||||
Creator<MotionEvent> | CREATOR | ||||||||||
int | EDGE_BOTTOM | Flag indicating the motion event intersected the bottom edge of the screen. | |||||||||
int | EDGE_LEFT | Flag indicating the motion event intersected the left edge of the screen. | |||||||||
int | EDGE_RIGHT | Flag indicating the motion event intersected the right edge of the screen. | |||||||||
int | EDGE_TOP | Flag indicating the motion event intersected the top edge of the screen. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.os.Parcelable
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a new movement to the batch of movements in this event.
| |||||||||||
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
| |||||||||||
Return the kind of action being performed -- one of either
ACTION_DOWN, ACTION_MOVE, ACTION_UP, or
ACTION_CANCEL.
| |||||||||||
Return the id for the device that this event came from.
| |||||||||||
Returns the time (in ms) when the user originally pressed down to start
a stream of position events.
| |||||||||||
Returns a bitfield indicating which edges, if any, where touched by this
MotionEvent.
| |||||||||||
Returns the time (in ms) when this specific event was generated.
| |||||||||||
Returns the time that a historical movement occurred between this event
and the previous event.
| |||||||||||
Returns a historical pressure coordinate that occurred between this event
and the previous event.
| |||||||||||
Returns a historical size coordinate that occurred between this event
and the previous event.
| |||||||||||
Returns a historical X coordinate that occurred between this event
and the previous event.
| |||||||||||
Returns a historical Y coordinate that occurred between this event
and the previous event.
| |||||||||||
Returns the number of historical points in this event.
| |||||||||||
Returns the state of any meta / modifier keys that were in effect when
the event was generated.
| |||||||||||
Returns the current pressure of this event.
| |||||||||||
Returns the original raw X coordinate of this event.
| |||||||||||
Returns the original raw Y coordinate of this event.
| |||||||||||
Returns a scaled value of the approximate size, of the area being pressed when
touched with the finger.
| |||||||||||
Returns the X coordinate of this event.
| |||||||||||
Return the precision of the X coordinates being reported.
| |||||||||||
Returns the Y coordinate of this event.
| |||||||||||
Return the precision of the Y coordinates being reported.
| |||||||||||
Create a new MotionEvent, copying from an existing one.
| |||||||||||
Create a new MotionEvent, filling in a subset of the basic motion
values.
| |||||||||||
Create a new MotionEvent, filling in all of the basic values that
define the motion.
| |||||||||||
Adjust this event's location.
| |||||||||||
Recycle the MotionEvent, to be re-used by a later caller.
| |||||||||||
Sets this event's action.
| |||||||||||
Sets the bitfield indicating which edges, if any, where touched by this
MotionEvent.
| |||||||||||
Set this event's location.
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
| |||||||||||
Flatten this object in to a Parcel.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface android.os.Parcelable
|
Constant for getAction(): The current gesture has been aborted. You will not receive any more points in it. You should treat this as an up event, but not perform any action that you normally would.
Constant for getAction(): A pressed gesture has started, the motion contains the initial starting location.
Constant for getAction(): A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP). The motion contains the most recent point, as well as any intermediate points since the last down or move event.
Constant for getAction(): A movement has happened outside of the normal bounds of the UI element. This does not provide a full gesture, but only the initial location of the movement/touch.
Constant for getAction(): 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.
Flag indicating the motion event intersected the bottom edge of the screen.
Flag indicating the motion event intersected the left edge of the screen.
Flag indicating the motion event intersected the right edge of the screen.
Flag indicating the motion event intersected the top edge of the screen.
Add a new movement to the batch of movements in this event. The event's current location, position and size is updated to the new values. In the future, the current values in the event will be added to a list of historic values.
x | The new X position. |
---|---|
y | The new Y position. |
pressure | The new pressure. |
size | The new size. |
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
Return the kind of action being performed -- one of either ACTION_DOWN, ACTION_MOVE, ACTION_UP, or ACTION_CANCEL.
Return the id for the device that this event came from. An id of zero indicates that the event didn't come from a physical device; other numbers are arbitrary and you shouldn't depend on the values.
Returns the time (in ms) when the user originally pressed down to start a stream of position events.
Returns a bitfield indicating which edges, if any, where touched by this MotionEvent. For touch events, clients can use this to determine if the user's finger was touching the edge of the display.
Returns the time (in ms) when this specific event was generated.
Returns the time that a historical movement occurred between this event and the previous event. Only applies to ACTION_MOVE events.
pos | Which historical value to return; must be less than getHistorySize() |
---|
Returns a historical pressure coordinate that occurred between this event and the previous event. Only applies to ACTION_MOVE events.
pos | Which historical value to return; must be less than getHistorySize() |
---|
Returns a historical size coordinate that occurred between this event and the previous event. Only applies to ACTION_MOVE events.
pos | Which historical value to return; must be less than getHistorySize() |
---|
Returns a historical X coordinate that occurred between this event and the previous event. Only applies to ACTION_MOVE events.
pos | Which historical value to return; must be less than getHistorySize() |
---|
Returns a historical Y coordinate that occurred between this event and the previous event. Only applies to ACTION_MOVE events.
pos | Which historical value to return; must be less than getHistorySize() |
---|
Returns the number of historical points in this event. These are movements that have occurred between this event and the previous event. This only applies to ACTION_MOVE events -- all other actions will have a size of 0.
Returns the state of any meta / modifier keys that were in effect when the event was generated. This is the same values as those returned by KeyEvent.getMetaState.
Returns the current pressure of this event. The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), however values higher than 1 may be generated depending on the calibration of the input device.
Returns the original raw X coordinate of this event. For touch events on the screen, this is the original location of the event on the screen, before it had been adjusted for the containing window and views.
Returns the original raw Y coordinate of this event. For touch events on the screen, this is the original location of the event on the screen, before it had been adjusted for the containing window and views.
Returns a scaled value of the approximate size, of the area being pressed when touched with the finger. The actual value in pixels corresponding to the finger 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.
Returns the X coordinate of this event. Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
Return the precision of the X coordinates being reported. You can multiple this number with getX() to find the actual hardware value of the X coordinate.
Returns the Y coordinate of this event. Whole numbers are pixels; the value may have a fraction for input devices that are sub-pixel precise.
Return the precision of the Y coordinates being reported. You can multiple this number with getY() to find the actual hardware value of the Y coordinate.
Create a new MotionEvent, copying from an existing one.
Create a new MotionEvent, filling in a subset of the basic motion values. Those not specified here are: device id (always 0), pressure and size (always 1), x and y precision (always 1), and edgeFlags (always 0).
downTime | The time (in ms) when the user originally pressed down to start a stream of position events. This must be obtained from uptimeMillis(). |
---|---|
eventTime | The the time (in ms) when this specific event was generated. This must be obtained from uptimeMillis(). |
action | The kind of action being performed -- one of either ACTION_DOWN, ACTION_MOVE, ACTION_UP, or ACTION_CANCEL. |
x | The X coordinate of this event. |
y | The Y coordinate of this event. |
metaState | The state of any meta / modifier keys that were in effect when the event was generated. |
Create a new MotionEvent, filling in all of the basic values that define the motion.
downTime | The time (in ms) when the user originally pressed down to start a stream of position events. This must be obtained from uptimeMillis(). |
---|---|
eventTime | The the time (in ms) when this specific event was generated. This must be obtained from uptimeMillis(). |
action | The kind of action being performed -- one of either ACTION_DOWN, ACTION_MOVE, ACTION_UP, or ACTION_CANCEL. |
x | The X coordinate of this event. |
y | The Y coordinate of this event. |
pressure | The current pressure of this event. The pressure generally ranges from 0 (no pressure at all) to 1 (normal pressure), however values higher than 1 may be generated depending on the calibration of the input device. |
size | A scaled value of the approximate size of the area being pressed when touched with the finger. The actual value in pixels corresponding to the finger touch is normalized with a device specific range of values and scaled to a value between 0 and 1. |
metaState | The state of any meta / modifier keys that were in effect when the event was generated. |
xPrecision | The precision of the X coordinate being reported. |
yPrecision | The precision of the Y coordinate being reported. |
deviceId | The id for the device that this event came from. An id of zero indicates that the event didn't come from a physical device; other numbers are arbitrary and you shouldn't depend on the values. |
edgeFlags | A bitfield indicating which edges, if any, where touched by this MotionEvent. |
Adjust this event's location.
deltaX | Amount to add to the current X coordinate of the event. |
---|---|
deltaY | Amount to add to the current Y coordinate of the event. |
Recycle the MotionEvent, to be re-used by a later caller. After calling this function you must not ever touch the event again.
Sets this event's action.
Sets the bitfield indicating which edges, if any, where touched by this MotionEvent.
Set this event's location. Applies offsetLocation(float, float) with a delta from the current location to the given new location.
x | New absolute X location. |
---|---|
y | New absolute Y location. |
Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation simply concatenates the class name, the '@' sign and a hexadecimal representation of the object's hashCode(), that is, it is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Flatten this object in to a Parcel.
out | The Parcel in which the object should be written. |
---|---|
flags | Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. |