title: Fade In Fade Out Android Animation in Java
body: <p>I want to have a 2 second animation of an ImageView that spends 1000ms fading in and then 1000ms fading out.</p>
  
  <p>Here's what I have so far in my ImageView constructor:</p>
  
  <pre><code>Animation fadeIn = new AlphaAnimation(0, 1);
  fadeIn.setDuration(1000);
  
  Animation fadeOut = new AlphaAnimation(1, 0);
  fadeOut.setStartOffset(1000);
  fadeOut.setDuration(1000);
  
  AnimationSet animation = new AnimationSet(true);
  animation.addAnimation(fadeIn);
  animation.addAnimation(fadeOut);
  this.setAnimation(animation);
  </code></pre>
  
  <p>When I run that animation, <em>nothing</em> shows up. However, when I remove one of the alpha animations, the behavior works as expected.</p>
  
  <p>Things I have already tried:</p>
  
  <ul>
  <li>Every conceivable combination of <code>setFillBefore</code>, <code>setFillAfter</code>, and <code>setFillEnabled</code>.</li>
  <li>Adding a <code>LinearInterpolator</code> to the <code>AnimationSet</code>.</li>
  </ul>