Sean
Sean

Reputation: 179

is there a way to slow down translate animation while its being executed?

How can I control the speed of the animation? The translate animation goes from bottom to top and I'd like to slow down the animation during the time its being executed. How can I achieve this? Here is what I have:

public void SlideToAbove() {

    Animation slide = null;
    slide = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            0.0f, Animation.RELATIVE_TO_SELF, 0.0f);

    slide.setDuration(300);
    slide.setFillAfter(true);
    slide.setFillEnabled(true);
    toolBar.startAnimation(slide);

    final Animation finalSlide = slide;
    slide.setAnimationListener(new Animation.AnimationListener() {


        public void onAnimationStart(Animation animation) {
        }


        public void onAnimationRepeat(Animation animation) {
        }


        public void onAnimationEnd(Animation animation) {


            CoordinatorLayout.LayoutParams lp = new CoordinatorLayout.LayoutParams(
                    toolBar.getWidth(), toolBar.getHeight());
            lp.setMargins(0, 0, 0, 0);
            appBarLayout.setLayoutParams(lp);
            finalSlide.setFillAfter(true);

        }

    });

Upvotes: 1

Views: 1016

Answers (1)

santosh kumar
santosh kumar

Reputation: 2962

Try this,

slide =new TranslateAnimation(-100f, 0f, 0f, 0f);
slide.setDuration(600);

Upvotes: 5

Related Questions