At the first click of a button, I want to slide a View
along the x-axis (by 200 pixels to the right let\'s say). And on the second press of the button, I want t
Try looking into ObjectAnimator and its super class Value Animator
you can do something like this
ObjectAnimator anim = ObjectAnimator.ofFloat(this, "translationX", 0,200);
and then
anim.start();
Use a boolean
value and toggle it with 200,0
in the object animator to slide back
PS: you can use setDuration
method to set how long the animation should take to complete
Try looking at the support library which provides backward compatibility.
As @AdilHussain pointed out there is a library called nineoldandroids which can be used for the same purpose on older androids.