我有一个图像(item_image)的ID,我想拿着它并将其拖到我的购物车中,购物车的ID是(view_cart)。
我尝试了perform_action('drag',fromX,toX,fromY,toY,steps),我使用了pan("* id:'element'",:right),它保留图像并将其向右拖动。
你能帮我吗?
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;
}
});
试试这个。