Search code examples
androidimageviewandroid-animationfade

Using fade method does not make appear images


I want to make an image appear one after the other, using the fade method, with an imageView. The effect with the first image is correct, but the second one is not displayed at all, skipping it to the third one. This is the code, I checked and the syntax is correct, as you can see the alpha is at 1.0, making the image fully visible. bart is both the name of the ImageView and of an image in the drawable folder

ImageView bart= (ImageView) findViewById(R.id.bart);
        bart.animate().alpha((float)1.0).setDuration(1000);
        bart.setImageResource(R.drawable.homer);
        bart.animate().alpha((float)1.0).setDuration(1000);
        bart.setImageResource(R.drawable.lisa);

Solution

  • You've just defined the animation, but never started it. add 'start()' at the end of the animation call chain.