Perform action on certain Y coordinate
<p>I'm trying to make a view invisible when it's dragged to a certain Y coordinate on the screen. 
This is what I got now:</p>

<pre><code>private final class dragTouchListener implements View.OnTouchListener {


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

        final int X = (int) event.getRawX();
        final int Y = (int) event.getRawY();
        switch (event.getAction() &amp; MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                ContentFrameLayout.LayoutParams lParams = (ContentFrameLayout.LayoutParams) v.getLayoutParams();
                _xDelta = X - lParams.leftMargin;
                _yDelta = Y - lParams.topMargin;
                break;
            case MotionEvent.ACTION_UP:
                trash_image.setVisibility(View.INVISIBLE);
                break;
            case MotionEvent.ACTION_POINTER_DOWN:
                break;
            case MotionEvent.ACTION_POINTER_UP:

                break;
            case MotionEvent.ACTION_MOVE:
                trash_image.setVisibility(View.VISIBLE);

                ContentFrameLayout.LayoutParams layoutParams = (ContentFrameLayout.LayoutParams) v.getLayoutParams();
                layoutParams.leftMargin = X - _xDelta;
                layoutParams.topMargin = Y - _yDelta;
                layoutParams.rightMargin = -250;
                layoutParams.bottomMargin = -250;
                v.setLayoutParams(layoutParams);

                if(v.getY() &gt; trash_image.getY()){
                    v.setVisibility(View.INVISIBLE);
                }

                break;
        }
        contentView.invalidate();
        return true;



    }

}
</code></pre>

<p>So basically what I've tried here is simply an if statement to check if the Y position of the view has "passed" that of another ImageView placed on the upper part of the screen. This however result in becoming invisible as soon as I touch the view to be dragged, no matter where on the screen it's located. So it's far from accurate, or wrong all together.</p>