//在onTouch 的 MotionEvent.ACTION_MOVE 下
float moveRawX = event.getRawX();
float moveRawY = event.getRawY();
params.x = (int)(moveRawX - mRootView.getWidth()/2) ;
params.y = (int)(moveRawY - mRootView.getHeight()/2) ;
windowManager.updateViewLayout(mRootView,params);
//在 MotionEvent.ACTION_UP:
int x = (int)(event.getRawX() - event.getX());
int y = (int)(event.getRawY() - event.getY() - statuBar);
SharedPrefeUtil.getInstance(mContext).putBackFloatXY(x,y);
网友评论