Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android view fade in programmatically

I'm adding an ImageView dynamically to my layout and then I want it to fade in. Unfortunately the image is added and then the animation is applied, so it has a flicker to it BEFORE the animation starts. I've tried to initially set the alpha to 0 then AlphaAnimate that in, but it never shows up. I tried using Invisible or Gone on the view visibility.

I'm using an AnimationSet to fade in with other animations, then wrapping that in another AnimationSet. Could this be the issue?

Code for animation is pretty simple. no tricks. but the view looks like it's added then taken away using this.

AlphaAnimation fadeIn = new AlphaAnimation(0,1);
fadeIn.setDuration(duration/3);
fadeIn.setFillAfter(true);
like image 374
Eric Novins Avatar asked Feb 28 '11 18:02

Eric Novins


1 Answers

Removing it from a nested AnimationSet solved the issue. I was doing an alpha/tranlate/scale in an AnimationSet, then doing 2 of those in another AnimationSet to do a zoom in/zoom out scenario

like image 59
Eric Novins Avatar answered Nov 04 '22 10:11

Eric Novins