MotionEvent常量篇

来源:互联网 发布:淘宝代理需要多少钱 编辑:程序博客网 时间:2024/06/05 21:50

Class Overview Object used to report movement (mouse, pen, finger,
trackball) events. Motion events may hold either absolute or relative
movements and other data, depending on the type of device.

MotionEvent是用于分别不同的运动(鼠标, 触摸笔, 手指, 跟踪球)事件。

这是官方的介绍,他不仅是一个用于封装屏幕点击事件的类,还可以用来处理鼠标,或者是跟踪球(这个搜索了下在游戏手柄上有应用)。

int ACTION_BUTTON_PRESS

按钮被点击的事件

int ACTION_BUTTON_RELEASE

按钮被释放的事件

int ACTION_CANCEL

一个动作正在进行的动作中断事件

int ACTION_DOWN

屏幕被点击事件

int ACTION_MASK

求动作的掩码(用于位运算的动作)

int ACTION_MOVE

在按下和抬起的时候触摸位置有变化

int ACTION_OUTSIDE

当触摸事件超出绑定的控件以外

int ACTION_POINTER_1_DOWN

在AP8以上的SDK不建议使用,用ACTION_POINTER_INDEX_MASK代替原本用于多点触控

int ACTION_POINTER_DOWN

多点触控的时候第二个点击事件

int ACTION_POINTER_ID_MASK

在API 8以上版本不建议使用,用ACTION_POINTER_INDEX_MASK代替
(其实就是觉得Index语义更加准确点,Match_parent和Fuil_Parent的区别)

int ACTION_POINTER_ID_SHIFT

在API 8以上版本不建议使用,用ACTION_POINTER_INDEX_SHIFT代替

int ACTION_POINTER_INDEX_MASK

用于和getAction中返回如果是ACTION_POINTER_DOWN多点触控,则可以进行
与运算然后再右移ACTION_POINTER_INDEX_SHIFT 位得到结果

int ACTION_POINTER_INDEX_SHIFT

用于CTION_POINTER_DOWN的到的结果右移的个数

int ACTION_POINTER_UP

多点触控的时候第二个点抬起的时候

int ACTION_SCROLL

用于标记水平或者是垂直滚动偏移

int ACTION_UP

抬起事件

int INVALID_POINTER_ID

无效的触控ID(个人觉得ID应该改成Index,因为在官方文档中解释是用于标记Pointer都用的是Index)

int ACTION_HOVER_ENTER Constant for getActionMasked(): The pointer is not down but has entered the >boundaries of a window or view.
int ACTION_HOVER_EXIT Constant for getActionMasked(): The pointer is not down but has exited the boundaries of >a window or view.
int ACTION_HOVER_MOVE Constant for getActionMasked(): A change happened but the pointer is not down
(unlike ACTION_MOVE).

以上三种都是官方文档解释没有按下却又进入,退出,移动在绑定的范围内,一般在view的onGenericMotionEvent(MotionEvent event)中处理。一开始我也很纳闷,没有按下却可以检查到。我就看了下
onGenericMotionEvent (MotionEvent event)的函数。那边有一句这样的注释

// process the mouse hover movement

当鼠标移动的动作。。。。。好吧,的确如此,真是很有趣啊!!

int TOOL_TYPE_ERASER Tool type constant: The tool is an eraser or a stylus being used in an inverted posture.
int TOOL_TYPE_FINGER Tool type constant: The tool is a finger.
int TOOL_TYPE_MOUSE Tool type constant: The tool is a mouse or trackpad.
int TOOL_TYPE_STYLUS Tool type constant: The tool is a stylus.
int TOOL_TYPE_UNKNOWN Tool type constant: Unknown tool type.

用于标记各种设备

int FLAG_WINDOW_IS_OBSCURED This flag indicates that the window that received this motion event is partly or
wholly obscured by another visible window above it.

这个标记没弄明白什么意思,特点去看了下源码,希望有人能解释下

int AXIS_BRAKE Axis constant: Brake axis of a motion event.
int AXIS_DISTANCE Axis constant: Distance axis of a motion event.
int AXIS_GAS Axis constant: Gas axis of a motion event.
int AXIS_GENERIC_1 Axis constant: Generic 1 axis of a motion event.
int AXIS_GENERIC_10 Axis constant: Generic 10 axis of a motion event.
int AXIS_GENERIC_11 Axis constant: Generic 11 axis of a motion event.
int AXIS_GENERIC_12 Axis constant: Generic 12 axis of a motion event.
int AXIS_GENERIC_13 Axis constant: Generic 13 axis of a motion event.
int AXIS_GENERIC_14 Axis constant: Generic 14 axis of a motion event.
int AXIS_GENERIC_15 Axis constant: Generic 15 axis of a motion event.
int AXIS_GENERIC_16 Axis constant: Generic 16 axis of a motion event.
int AXIS_GENERIC_2 Axis constant: Generic 2 axis of a motion event.
int AXIS_GENERIC_3 Axis constant: Generic 3 axis of a motion event.
int AXIS_GENERIC_4 Axis constant: Generic 4 axis of a motion event.
int AXIS_GENERIC_5 Axis constant: Generic 5 axis of a motion event.
int AXIS_GENERIC_6 Axis constant: Generic 6 axis of a motion event.
int AXIS_GENERIC_7 Axis constant: Generic 7 axis of a motion event.
int AXIS_GENERIC_8 Axis constant: Generic 8 axis of a motion event.
int AXIS_GENERIC_9 Axis constant: Generic 9 axis of a motion event.
int AXIS_HAT_X Axis constant: Hat X axis of a motion event.
int AXIS_HAT_Y Axis constant: Hat Y axis of a motion event.
int AXIS_HSCROLL Axis constant: Horizontal Scroll axis of a motion
event. int AXIS_LTRIGGER Axis constant: Left Trigger axis of a motion
event. int AXIS_ORIENTATION Axis constant: Orientation axis of a
motion event. int AXIS_PRESSURE Axis constant: Pressure axis of a
motion event. int AXIS_RTRIGGER Axis constant: Right Trigger axis of a
motion event. int AXIS_RUDDER Axis constant: Rudder axis of a motion
event. int AXIS_RX Axis constant: X Rotation axis of a motion event.
int AXIS_RY Axis constant: Y Rotation axis of a motion event.
int AXIS_RZ Axis constant: Z Rotation axis of a motion event.
int AXIS_SIZE Axis constant: Size axis of a motion event.
int AXIS_THROTTLE Axis constant: Throttle axis of a motion event.
int AXIS_TILT Axis constant: Tilt axis of a motion event.
int AXIS_TOOL_MAJOR Axis constant: ToolMajor axis of a motion event.
int AXIS_TOOL_MINOR Axis constant: ToolMinor axis of a motion event.
int AXIS_TOUCH_MAJOR Axis constant: TouchMajor axis of a motion event.
int AXIS_TOUCH_MINOR Axis constant: TouchMinor axis of a motion event.
int AXIS_VSCROLL Axis constant: Vertical Scroll axis of a motion
event.
int AXIS_WHEEL Axis constant: Wheel axis of a motion event.
int AXIS_X Axis constant: X axis of a motion event.
int AXIS_Y Axis constant: Y axis of a motion event.
int AXIS_Z Axis constant: Z axisof a motion event.
int BUTTON_BACK Button constant: Back button pressed (mouse back button).
int BUTTON_FORWARD Button constant: Forward button pressed (mouse forward button).
int BUTTON_PRIMARY Button constant: Primary button (left mouse button).
int BUTTON_SECONDARY Button constant: Secondary button (right mouse button).
int BUTTON_STYLUS_PRIMARY Button constant: Primary stylus button pressed.
int BUTTON_STYLUS_SECONDARY Button constant: Secondary stylus button pressed.
int BUTTON_TERTIARY Button constant: Tertiary button (middle mouse button).
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 leftedge of the screen.
int EDGE_RIGHT Flag indicating the motion event int ersected the right edge of the screen.
int EDGE_TOP Flag indicating the motion event intersected the top edge of the screen.

以上应该都是用于游戏手柄的开发我就不解释了。

int ACTION_BUTTON_PRESS
int ACTION_BUTTON_RELEASE

这两个事件都是在绑定Button控件的时候被检查到,别的控件式不能检测到的。并且Button控件不会ACTION_DOWN和UP的事件,为什么不清楚,下一次看看源码研究下

1 0
原创粉丝点击