Android: Fade view in and out

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);

This is an animation we used in our project. Spinner is a view so you can change this with your imageview. So indeed 2 images on top of eachother, one visible one invisible. This is how we did it. Hope it helps.

    spinner.setVisibility(View.VISIBLE);
    spinner.setAlpha(0);

    spinner.animate().setDuration(200).alpha(1).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            spinner.setVisibility(View.VISIBLE);
        }
    });

     infoActivityContent.animate().setDuration(200).alpha(0).setListener(new AnimatorListenerAdapter() {
       @Override
       public void onAnimationEnd(Animator animation) {
            infoActivityContent.setVisibility(View.GONE);

       mainPresenter.logout();
       }
     });