Reference:Android.view.MotionEvent
From Triled Wiki
android.view
public class android.view.MotionEvent
| java.lang.Object | ||
| android.view.MotionEvent | Parcelable | |
Object used to report movement (mouse, pen, finger) events.
[edit] Summary
[edit] Constants
| Value | ||||
|---|---|---|---|---|
| int | ACTION_CANCEL | 3 | 0x00000003 | |
| int | ACTION_DOWN | 0 | 0x00000000 | |
| int | ACTION_MOVE | 2 | 0x00000002 | |
| int | ACTION_UP | 1 | 0x00000001 | |
| Creator | CREATOR |
[edit] Public Constructors
| MotionEvent (long downTime, long eventTime, int action, float x, float y, float pressure, float size, float xPrecision, float yPrecision, int deviceId) | |||||
| MotionEvent (long downTime, long eventTime, int action, float x, float y) |
[edit] Public Methods
| final | void | addBatch (float x, float y, float pressure, float size) | |||
| Add a new movement to the batch of movements in this event. | |||||
| final | int | getAction () | |||
| Return the kind of action being performed - one of either ACTION_DOWN, ACTION_MOVE, ACTION_UP, or ACTION_CANCEL. | |||||
| final | int | getDeviceId () | |||
| Return the id for the device that this event came from. | |||||
| final | long | getDownTime () | |||
| Returns the time (in ms) when the user originally pressed down to start a stream of position events. | |||||
| final | long | getEventTime () | |||
| Returns the time (in ms) when this specific event was generated. | |||||
| final | float | getHistoricalPressure (int pos) | |||
| Returns a historical pressure coordinate that occurred between this event and the previous event. | |||||
| final | float | getHistoricalSize (int pos) | |||
| Returns a historical size coordinate that occurred between this event and the previous event. | |||||
| final | float | getHistoricalX (int pos) | |||
| Returns a historical X coordinate that occurred between this event and the previous event. | |||||
| final | float | getHistoricalY (int pos) | |||
| Returns a historical Y coordinate that occurred between this event and the previous event. | |||||
| final | int | getHistorySize () | |||
| Returns the number of historical points in this event. | |||||
| final | float | getPressure () | |||
| Returns the current pressure of this event. | |||||
| final | float | getRawX () | |||
| Returns the original raw X coordinate of this event. | |||||
| final | float | getRawY () | |||
| Returns the original raw Y coordinate of this event. | |||||
| final | float | getSize () | |||
| Returns the approximate size, in pixels, of the area being pressed. | |||||
| final | float | getX () | |||
| Returns the X coordinate of this event. | |||||
| final | float | getXPrecision () | |||
| Return the precision of the X coordinates being reported. | |||||
| final | float | getY () | |||
| Returns the Y coordinate of this event. | |||||
| final | float | getYPrecision () | |||
| Return the precision of the Y coordinates being reported. | |||||
| final | void | offsetLocation (float deltaX, float deltaY) | |||
| Adjust this event's location. | |||||
| final | void | setAction (int action) | |||
| Sets this event's action. | |||||
| final | void | setLocation (float x, float y) | |||
| Set this event's location. | |||||
| String | toString () | ||||
| Answers a string containing a concise, human-readable description of the receiver. | |||||
| void | writeToParcel (Parcel out) | ||||
[edit] Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait[edit] Methods inherited from interface android.os.Parcelable
[edit] Details
[edit] Constants
[edit] public static final int ACTION_CANCEL
Constant Value: 3 (0x00000003)
[edit] public static final int ACTION_DOWN
Constant Value: 0 (0x00000000)
[edit] public static final int ACTION_MOVE
Constant Value: 2 (0x00000002)
[edit] public static final int ACTION_UP
Constant Value: 1 (0x00000001)
[edit] public static final Creator CREATOR
[edit] Public Constructors
[edit] public MotionEvent(long downTime, long eventTime, int action, float x, float y, float pressure, float size, float xPrecision, float yPrecision, int deviceId)
[edit] public MotionEvent(long downTime, long eventTime, int action, float x, float y)
[edit] Public Methods
[edit] public final void addBatch(float x, float y, float pressure, float size)
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.
Parameters
| x | The new X position. |
|---|---|
| y | The new Y position. |
| pressure | The new pressure. |
| size | The new size. |
[edit] public final int getAction()
Return the kind of action being performed - one of either ACTION_DOWN, ACTION_MOVE, ACTION_UP, or ACTION_CANCEL.
[edit] public final int getDeviceId()
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.
[edit] public final long getDownTime()
Returns the time (in ms) when the user originally pressed down to start a stream of position events.
[edit] public final long getEventTime()
Returns the time (in ms) when this specific event was generated.
[edit] public final float getHistoricalPressure(int pos)
Returns a historical pressure coordinate that occurred between this event and the previous event. Only applies to ACTION_MOVE events.
Parameters
| pos | Which historical value to return; must be less than getHistorySize() |
|---|
See Also
[edit] public final float getHistoricalSize(int pos)
Returns a historical size coordinate that occurred between this event and the previous event. Only applies to ACTION_MOVE events.
Parameters
| pos | Which historical value to return; must be less than getHistorySize() |
|---|
See Also
[edit] public final float getHistoricalX(int pos)
Returns a historical X coordinate that occurred between this event and the previous event. Only applies to ACTION_MOVE events.
Parameters
| pos | Which historical value to return; must be less than getHistorySize() |
|---|
See Also
[edit] public final float getHistoricalY(int pos)
Returns a historical Y coordinate that occurred between this event and the previous event. Only applies to ACTION_MOVE events.
Parameters
| pos | Which historical value to return; must be less than getHistorySize() |
|---|
See Also
[edit] public final int 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
- Returns the number of historical points in the event.
[edit] public final float getPressure()
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.
[edit] public final float getRawX()
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.
[edit] public final float getRawY()
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.
[edit] public final float getSize()
Returns the approximate size, in pixels, of the area being pressed. This provides a basic indication of accuracy - the actual position being pressed by the user is somewhere this number of pixels from the X and Y coordinate reported in the event.
[edit] public final float getX()
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.
[edit] public final float getXPrecision()
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
- Returns the precision of X coordinates being reported.
[edit] public final float getY()
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.
[edit] public final float getYPrecision()
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.
Returns
- Returns the precision of Y coordinates being reported.
[edit] public final void offsetLocation(float deltaX, float deltaY)
Adjust this event's location.
Parameters
| deltaX | Amount to add to the current X coordinate of the event. |
|---|---|
| deltaY | Amount to add to the current Y coordinate of the event. |
[edit] public final void setAction(int action)
Sets this event's action.
[edit] public final void setLocation(float x, float y)
Set this event's location. Applies offsetLocation(float, float) with a delta from the current location to the given new location.
Parameters
| x | New absolute X location. |
|---|---|
| y | New absolute Y location. |
[edit] public String toString()
Answers a string containing a concise, human-readable description of the receiver.
[edit] public void writeToParcel(Parcel out)
[edit] References
- Original documentation page for Android SDK build m5-rc15e - 14 apr 2008 17:27
