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
Edit :
Try looking at the support library which provides backward compatibility.
Edit
As @AdilHussain pointed out there is a library called nineoldandroids which can be used for the same purpose on older androids.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…