I want to be able to drag a view horizontally in a smooth way. I use the following code
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
{
\\setup before dragging
}
break;
case MotionEvent.ACTION_MOVE:
{
v.setX((dx += speedFactor));
}
break;
case MotionEvent.ACTION_UP:
{
\\setup after dragging
}
return true;
}
return true;
}
when I use a small speedFactore < 10 the animation is smooth but the view moves very slowly. When I increase it it doesn't move as smooth as I wish.
How to dragging very smooth and a little bit faster?