Here's the solution i got:
private float xCoOrdinate, yCoOrdinate;
view.setOnTouchListener(new View.OnTouchListener() {
Float y1 = 0f, y2 = 0f;
@Override
public boolean onTouch(View v, MotionEvent event) {
Point size = new Point();
getWindowManager().getDefaultDisplay().getSize(size);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
//xCoOrdinate = view.getX() - event.getRawX();
yCoOrdinate = view.getY() - event.getRawY();
Float puffer = 0f;
y1 = event.getRawY();
break;
case MotionEvent.ACTION_MOVE:
view.animate().y(event.getRawY() + yCoOrdinate).setDuration(0).start();
//view.animate().x(event.getRawX() + xCoOrdinate).y(event.getRawY() + yCoOrdinate).setDuration(0).start();
break;
case MotionEvent.ACTION_UP:
y2 = event.getRawY();
Float dy = (y2 - y1);
if (dy < 0) {
//moved up
view.animate().y(size.y / 100 * -40).setDuration(100).start();
} else if (dy > 0) {
// moved down
view.animate().y(size.y / 2 - view.getHeight() / 2).setDuration(100).start();
}
break;
}
return false;
}
});
Explanation: I only needed motion on y-axis and dectection if moved up or down. It's done by animating the view to the touch, witch has pros and contras (contra: its complicated to detect where view is in space / pro: the view actually moves and doesnt just appear to be somewhere else) but turned out to work best for me and is quite simple. The goal here is to swipe the view up and get it to a desired spot, same as swipe down, back to original position, this is achieved relativ to screen size. To me the code is relative simple and selfexplainatory, but please ask if anything unclear.