When used with care, animation can be much more than a mere gimmick—it can improve the quality of the user experience. Subtlety is the key to using animation effectively: the best UI animations are the ones your users don’t notice because they feel natural.

I created a small helper class called FadeImageView that wraps Android’s standard ImageView, applying an automatic fade transition when changing pictures. I have started using this class everywhere that I would normally use an ImageView.

The animated fading effect is particularly nice in cases where a placeholder image is later replaced with an image that is downloaded from the Internet. The result is a smooth transition that makes the change less jarring.

Without further ado, the following is the code:

To use it, replace occurences of ImageView with FadeImageView. You can use it in Android XML layouts or in code. To activate the animation, simply use the overload accepting a boolean.