How could you animate for example a LinearLayout
that houses a banner, with animation SlideUp
to show it and SlideDown
to hide it altogether Toggle
.
I want to create a banner visualizer of its own, that detects when it has been hidden to load the next banner from a list.
I have the following:
final View banner = findViewById(R.id.banner);
banner.animate()
.translationY(banner.getHeight())
.alpha(0.0f)
.setDuration(650)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
//Carga del nuevo banner para volver a mostrar
banner.animate()
.translationY(0)
.alpha(1.0f)
.setDuration(650);
}
});
But I find that the animation is only done once.
Let's say when you launch the action, perform slide Down
and when you finish slide Up
, the second time I give you to perform the action does not slide
but applies fadeOut
and fadeIn
, it's as if it happened completely from .translationY(banner.getHeight())
How can it be resolved that the animation can be repeated as many times as necessary?
The purpose is that it is within a Runable
that every N seconds the action of loading the banner is applied.