Search code examples
androidtranslate-animation

TranslateAnimation in reverse position?


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);
}

Solution

  • Try to use this code

    toptranslateanimation.setRepeatCount(1);
    toptranslateanimation.setRepeatMode(Animation.REVERSE);