I need to display an image button that fades in and out (and in and out and so on...) The transparency can be set with setAlpha but how can I fade in and out? I mean I cannot do it on another thread because you need to do such things on the UI thread, right?
I guess it can be done with animations but I haven't found anything, because I don't have any experience with animations and don't really know what to search for...
Actually what I really want is to fade one image in and another one out but I guess the easiest way is to place the first image button below the second and just fade the second one. Or is there an easier way to do it?
In android, Fade In and Fade Out animations are used to change the appearance and behavior of the objects over a particular interval of time. The Fade In and Fade Out animations will provide a better look and feel for our applications.
use setVisibility method. for hiding button you can use button. setVisibility(View. GONE);.. you can use View.
An animation that controls the alpha level of an object. Useful for fading things in and out. This animation ends up changing the alpha property of a Transformation.
Here is the solution I'm using now, that works on API level lower than 12:
AlphaAnimation anim = new AlphaAnimation(1.0f, 0.0f); anim.setDuration(1000); anim.setRepeatCount(NUM_REPEATS); anim.setRepeatMode(Animation.REVERSE); button.startAnimation(anim);
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