title: Using animation on a ViewPager and setFillAfter
body: <p>I have a ViewPager which I need to move as a whole on button press. I use an animation for this.</p>
  
  <p>When I press it, I translate the 'x' for it. I use setFillAfter(true) to keep the new position. 
  But when I change the page of the ViewPager, it jumps back to the original x-position!</p>
  
  <p>I only saw this issue on Android 4.1, with Android 4.0 there is no problem! So it looks like some kind of regression in Android.</p>
  
  <p>I attached a testproject where I could reproduce the issue without all my other stuff around it. I think it is best if you want to help me figure this out to import the project in your Eclipse and see it for yourself.</p>
  
  <p>I also added to video's, one on my HTC One X where I see the issue, and the other on a tablet with Android 4.0, where the issue is not there.</p>
  
  <p>I have been desperately looking to fix this ugly side effect, but no luck till now...</p>
  
  <p>(Sorry for the big movie files...)</p>
  
  <p><a href="https://dl.dropboxusercontent.com/u/14093857/android_4.0-no_problem.MOV" rel="nofollow">Video of Android 4.0 without the side effect</a></p>
  
  <p><a href="https://dl.dropboxusercontent.com/u/14093857/pageviewer-animationbug_on_android_4.1.MOV" rel="nofollow">Video Android 4.1 with the side effect </a></p>
  
  <p><a href="https://dl.dropboxusercontent.com/u/14093857/viewPagerAnimTest.zip" rel="nofollow">the project where you can reproduce the issue with</a></p>
  
  <p>Edit:</p>
  
  <p>I added the following:</p>
  
  <pre><code>@Override
  public void onAnimationEnd(Animation animation) {
      RelativeLayout.LayoutParams lp = (android.widget.RelativeLayout.LayoutParams) myViewPager.getLayoutParams();
      if (!i)
          lp.setMargins(300,0,0,0);
      else
          lp.setMargins(0,0,0,0);
  
      myViewPager.setLayoutParams(lp);
  }
  </code></pre>
  
  <p>After that it stays at the correct position, but it 'flickers' quickly, like the animation is still showing at the end and when I change the margin, it still shows the offset it had after animation. Then it jumps to the correct position.</p>