Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android alpha animation: Staying in last animation frame when animation is completed

I'm fading out an imageview with alpha animation. I'd like the image to stay transparent after the animation. Tried with different combinations of fillAfter and fillEnabled, no luck. How can this be achieved?

pom

like image 817
Pompair Avatar asked Nov 17 '10 20:11

Pompair


2 Answers

setting fillEnabled and fillAfter to true always works for me.

anim = new AlphaAnimation(0.3f, 1.0f);
anim.setDuration(500);
anim.setFillEnabled(true);
anim.setFillAfter(true);
<view>.startAnimation(anim);
like image 147
pmko Avatar answered Nov 15 '22 07:11

pmko


Add an Animation.AnimationListener to the Animation via setAnimationListener(). In onAnimationEnd() of the listener, call setVisibility(View.INVISIBLE) on the ImageView.

like image 38
CommonsWare Avatar answered Nov 15 '22 07:11

CommonsWare