I am working on app in which i used TranslateAnimation but i want to reverse TranslateAnimation to start position.
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.imageviewactivity);
TranslateAnimation toptranslateanimation = new TranslateAnimation(0, 0, tempBar,
scanner_image.getHeight() - 50);
toptranslateanimation.setDuration(4000);
toptranslateanimation.setAnimationListener(this);
scanning_bar.setAnimation(toptranslateanimation);
}
Try to use this code
toptranslateanimation.setRepeatCount(1);
toptranslateanimation.setRepeatMode(Animation.REVERSE);
use Interpolator for that Like,
package com.example.android;
import android.view.animation.Interpolator;
public class ReverseInterpolator implements Interpolator {
@Override
public float getInterpolation(float paramFloat) {
return Math.abs(paramFloat -1f);
}
}
Then on your animation you can set your new interpolator:
toptranslateanimation.setInterpolator(new ReverseInterpolator());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With