I am performing a fade effect on a button.
AnimationSet set = new AnimationSet(true);
Animation animation2 = new AlphaAnimation((float) 0, 1);
animation2.setDuration(1500);
animation2.setRepeatMode(0);
set.addAnimation(animation2);
set.setFillAfter(true); // leaves the animation in its final status
btn.startAnimation(set);
I am using the setFillAfter(true)
option to leave the button visible. That works fine. Now I would like to perform the animation again, but can't never set again my button to be invisible on the screen, unless I restart the app. (alos tried invalidate() with no success...)
Any idea would be "so" welcome.
Thanks in advance! Paul
Thank you for you help. Actually I found the answer on the developpers doc. There is a big difference between "View animation" (which I tried to do) and "Property Animation". Basically View animation redraws an image of the view you are working on, but does not affect the original view. So If you translate your view from example, on the screen the view is moved but programatically it remained in its initial state and will catch events in its original position.
Here is the explanation:
http://developer.android.com/guide/topics/graphics/prop-animation.html
For my case I used Property animation and it matches all my animation needs. Thank you for your support! :)
Paul
take out
set.setFillAfter(true);
and use an animationListener to set the Button to visible when the animation finishes, it will give the same effect to the user, and you'll be able to make it invisible again withView.setVisibility(View.INVISIBLE);