0

我有一个图像的 ID (item_image),我想拿着它并将它拖到我的购物车,购物车的 ID 是 (view_cart)。

我尝试了 perform_action('drag',fromX,toX,fromY,toY,steps) 并使用了 pan("* id:'element'", :right) 来保存图像并将其拖动到右侧。

请问你能帮帮我吗?

4

1 回答 1

1
floctingicon.setOnTouchListener(new View.OnTouchListener() {
 private WindowManager.LayoutParams paramsF = params;
private int initialX;
private int initialY;
private float initialTouchX;
private float initialTouchY;

@Override
public boolean onTouch(View v, MotionEvent event) {

 switch (event.getAction()) {
 case MotionEvent.ACTION_DOWN:

  // Get current time in nano seconds.

  initialX = paramsF.x;
  initialY = paramsF.y;
  initialTouchX = event.getRawX();
  initialTouchY = event.getRawY();
  break;
 case MotionEvent.ACTION_UP:
  break;
 case MotionEvent.ACTION_MOVE:
  paramsF.x = initialX
    + (int) (event.getRawX() - initialTouchX);
  paramsF.y = initialY
    + (int) (event.getRawY() - initialTouchY);
  windowManager.updateViewLayout(floctingicon, paramsF);
  break;
 }
 return false;
}
});

尝试这个。

于 2015-04-28T14:07:57.980 回答