title: Android: animation works by code but not by xml
body: <p>I have a very simple animation: an imageview has to go up and then down all the time. Initially I tried with xml:</p>
  
  <pre><code>&lt;set xmlns:android="http://schemas.android.com/apk/res/android"
   android:shareInterpolator="false"
   android:fillAfter="true"&gt;
  &lt;set
      android:interpolator="@android:anim/linear_interpolator"
      android:repeatCount="-1"
      android:repeatMode="reverse"&gt;
      &lt;translate
          android:fromYDelta="0"
          android:toYDelta="10"
          android:duration="300"&gt;
      &lt;/translate&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>Animation mAnimation= AnimationUtils.loadAnimation(this, R.anim.myanimation);
  immagineNemico.startAnimation(mAnimation);
  </code></pre>
  
  <p>But it didn't work:my imageview didn't go up, only down. So I read an answer of a question and I did the animation by code:</p>
  
  <pre><code>    immagineNemico.setVisibility(View.VISIBLE);
      TranslateAnimation mAnimation = new TranslateAnimation(
              TranslateAnimation.ABSOLUTE, 0f,
              TranslateAnimation.ABSOLUTE, 0f,
              TranslateAnimation.RELATIVE_TO_PARENT, 0f,
              TranslateAnimation.RELATIVE_TO_PARENT, 0.02f);
      mAnimation.setDuration(300);
      mAnimation.setRepeatCount(-1);
      mAnimation.setRepeatMode(Animation.REVERSE);
      mAnimation.setInterpolator(new LinearInterpolator());
      immagineNemico.setAnimation(mAnimation);
  </code></pre>
  
  <p>And it worked. But why didn't the xml animation work? They are almost the same! Where is the error?</p>