[android]代码库
enter.setOnTouchListener(new OnTouchListener() {
int[] temp = new int[]{ 0, 0};
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
int x = (int)arg1.getRawX();
int y = (int)arg1.getRawY();
switch (arg1.getAction()) {
case MotionEvent.ACTION_DOWN:
temp[0] = (int)arg1.getX();
temp[1] = y - arg0.getTop();
Log.e("suo", "ACTION_DOWN");
break;
case MotionEvent.ACTION_MOVE:
arg0.layout(x - temp[0], y - temp[1], x - temp[0] + arg0.getWidth(), y - temp[1] + arg0.getHeight());
arg0.postInvalidate();
Log.e("suo", "ACTION_MOVE");
break;
case MotionEvent.ACTION_UP:
Log.e("suo", "ACTION_UP");
break;
default:
break;
}
return false;
}
});