I have a view which I have to make it draggable. After the user leaves the drag it is to be animated down from current position. Now for dragging I have used the below code
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
dY = view.getY() - event.getRawY();
rawY = event.getRawY();
break;
case MotionEvent.ACTION_MOVE:
if ((event.getRawY() - rawY) < 0) {
isDragging = false;
return false;
}
isDragging = true;
view.animate()
.y(event.getRawY() + dY)
.setDuration(0)
.start();
break;
case MotionEvent.ACTION_UP:
if (!isDragging) {
return false;
}
animateContainer();
return true;
default:
return false;
}
return true;
The dragging is working fine, and after the container is animated down when user releases the drag. But when I press the button to open the container again it is not taking it's original height. It is back to last drag position.
What can I do to solve this. Thanks