Matthias Prodani Matthias Prodani - 3 months ago 6x
Java Question

Waiting for ImageView.animate() to end before proceeding with the rest of the code

I'm a beginner learning android development and I was trying to make an image switch using fade in and out animation using ImageView.animate().alpha(); what I found is that the image changed before the animation finished so no animation was seen.

my code is

ImageView image = (ImageView)findViewById(;

Thanks in advance,


For waiting for the animation end you might use this example from the Android site and setListener method.

If you want the view to become visible you need to set alpha(1f). Also, try setImageResource before animation (switch line 3 with 2).