1

So, I want the image to move partly out of the screen but it doesn't. It always picks up where my finger is touching the screen. I tried doing other calculations but I can't do it. Is there a way for me to move the image out of the screen for all sides of the screen?

I'm using a 400x400dp picture and want all of them to be partly out of the screen.

@Override
public boolean onTouch(View v, MotionEvent event) {
    switch(event.getAction()){
        case MotionEvent.ACTION_DOWN:
            moving = true;
            break;
        case MotionEvent.ACTION_MOVE:
            if(moving){
                x = event.getRawX() - image.getWidth()/2; // The current calculations
                y = event.getRawY() - image.getHeight()*3/2;
                image.setX(x);
                image.setY(y);
            }
            break;
        case MotionEvent.ACTION_UP:
            moving = false;
            break;
    }
    return true;
}

0 Answers0