I would need to move TextView only up and down. I have this code, but using it you can move TextView in any direction:
textView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
int eid = event.getAction();
switch (eid) {
case MotionEvent.ACTION_MOVE:
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) textView.getLayoutParams();
int x = (int) event.getRawX();
int y = (int) event.getRawY();
layoutParams.leftMargin = x - 200;
layoutParams.topMargin = y - 250;
textView.setLayoutParams(layoutParams);
break;
default:
break;
}
return true;
}
});
Is there a way to move TextView only up and down?
Aucun commentaire:
Enregistrer un commentaire