Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear animation in right way

I am confused with a problem:

Animation animation = new TranslateAnimation(0, 0, 200, 0);
animation.setDuration(800);
animation.setFillAfter(true);

btnView.startAnimation(animation);
btnView.setVisibility(View.VISIBLE);

I run this code work right but when I add the below code:

btnView.clearAnimation();

The animation can't show, how to clear animation after this?

like image 311
dawei Avatar asked Sep 22 '14 03:09

dawei


People also ask

How do I change the direction of an animation?

On the slide, select the animation effect that you want to change. On the Animations tab, under Animation Options, click Effect Options, and then click Reverse Path Direction. Tip: To preview all animation effects on the slide, on the Animations tab, under Preview, click Play.

How do I turn off animation settings?

Open Settings . Scroll down and select Accessibility. Scroll down to Display and tap Text and display. Tap the toggle switch for Remove animations to turn it on.

How do you remove custom Animations in PowerPoint?

To get rid of all the animations on a slide, it's easiest to select all the objects on the slide by pressing Ctrl+A. Then you can select the “None” option on the “Animations” tab to remove all the animations from the slide. Repeat this process for each slide in the presentation, and you'll be animation free in no time.


2 Answers

if you want to clear the animations for the view once the animations i finished

you have to override Animation Listener of view and then clear the animation

if you want your view to move back to intial postion just setFillafter(false);

animation.setAnimationListener(new AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {


            }

            @Override
            public void onAnimationRepeat(Animation animation) {


            }

            @Override
            public void onAnimationEnd(Animation animation) {
                // TODO set params of the view to required position

            }
        });
like image 198
SHASHIDHAR MANCHUKONDA Avatar answered Sep 18 '22 16:09

SHASHIDHAR MANCHUKONDA


To clear animation after it is finished set setFillAfter to false.

like image 26
Bracadabra Avatar answered Sep 19 '22 16:09

Bracadabra