In the observe method of a view model, a new Observer is listening for an API response which is working correctly. However based on the response, it is calling the following code to show a success or failure image.
This code is inside its own method, called each time that the image should be shown:
I can only get the image to show once, subsequent method calls do not show any image, even though during debugging we are reaching every line.
The imageView box is correctly aligned in the XML and set to gone initially. (Tried invisible too).
imageView.setVisibility(View.VISIBLE); //Fade in imageView.animate().alpha(1).setDuration(1000); if(!successful) { imageView.setImageDrawable(getResources().getDrawable(R.drawable.failed_img)); } else { imageView.setImageDrawable(getResources().getDrawable(R.drawable.success_img)); } //Fade out imageView.animate().alpha(0).setDuration(1500).setStartDelay(1000);
I find your second animation effects the first animation. You can see below, the second animation should wait the fist animation finished.