I am trying to have a view animated in my app and am using NineOldAndroid for animations.
The desired effect is to fade the view out and then set it's visibility to gone so that it doesn't get clicked while invisible. Here is How I do it.
ViewPropertyAnimator.animate(view).alpha(0).setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(View.GONE);
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
The problem here is that the listener above sticks with the view
and when I try to fade it in again the listener gets called again resulting the view to be GONE
upon appearing.
ViewPropertyAnimator.animate(enterGallery).alpha(1);
How can I clear the listener after the view visibility is set to GONE
in the first piece of code?
I found the solution and it would be to pass null as listener when making the view VISIBLE
.
ViewPropertyAnimator.animate(view).alpha(1).setListener(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With