I managed to have a relative layout with an image in the middle over a constraint layout - this image should be shown instead of a Toast-Message (fade in => fade out)
When the app starts - just to prove that it works - it shows that image from the XML settings (thumb up / visibility).
Now I want to use the following function to change the image:
public void showThumbs(Integer like){
if (like > 0){
overlayout.bringToFront();
overlay.setImageResource(R.drawable.like);
overlay.bringToFront();
overlay.animate().alpha(1.0f).setDuration(800);
overlay.animate().alpha(0.0f).setDuration(800);
}
if (like < 0){
overlayout.bringToFront();
overlay.setImageResource(R.drawable.dislike);
overlay.bringToFront();
overlay.animate().alpha(1.0f).setDuration(800);
overlay.animate().alpha(0.0f).setDuration(800);
}
}
I tried to work with visibility which did not work and now I tried the animation fader.
What happens is this:
At the beginning it shows the thumb up as set in the XML-layout itself - OK
When I set like to a negative value it changes the image and fades it out
When I set like to a positive value it uses the thumbs up and fades it out
But it only works fades the image the first time and only the fade out part. As soon as it is gone I can call this function again an again and it will not show any picture anymore.
Any idea where my mistake is?
It should work like a Toast-Message (Fade in => Fade out).