I have a layout which contains text
and wraps it. I need to move this layout
vertically on the screen.
This is what I do.
View valuesContainer = view.findViewById(R.id.valuesContainer);
valuesContainer.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) v.getLayoutParams();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
oldY = (int)event.getRawY();
initialTopMargin = params.topMargin;
break;
case MotionEvent.ACTION_MOVE:
newY = (int)event.getY();
params.topMargin = (int) (initialTopMargin - (oldY - newY));
v.setLayoutParams(params);
}
break;
}
return true;
}
});
This moves the layout vertically on the screen. But now, I need this layout to go back to it's original place when I quit the finger of the screen.
Any code would be appriciated