本文将详细讲解MotionEvent类的一些成员和方法。
了解MotionEvent,可以更好地了解控件的一些特效,如拖动控件或多点缩放控件。同时,掌握MotionEvent类也是学好android触控技术的基础。
了解MotionEvent,可以更好地了解控件的一些特效,如拖动控件或多点缩放控件。同时,掌握MotionEvent类也是学好android触控技术的基础。
一、MotionEvent常见的常量
1)单点动作
ACTION_DOWN |
A pressed gesture has started, the motion contains the initial starting location. public static final int ACTION_DOWN = 0; 单点触摸动作 |
ACTION_UP |
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. public static final int ACTION_UP = 1;单点触摸离开动作 |
ACTION_OUTSIDE |
A movement has happened outside of the normal bounds of the UI element. public static final int ACTION_OUTSIDE= 4;触摸动作超出边界 |
ACTION_CANCEL |
The current gesture has been aborted public static final int ACTION_CANCEL = 3;触摸动作取消. |
ACTION_MOVE |
A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP). public static final int ACTION_MOVE= 2;触摸点移动动作 |
2)多点动作
ACTION_POINTER_DOWN | public static final int ACTION_POINTER_DOWN = 5; 多点触摸动作 |
ACTION_POINTER_UP | public static final int ACTION_POINTER_UP = 6; 多点离开动作 |