title: Android - Change left margin using animation
body: <p>I am changing the left margin of an image view in the following manner :</p>
  
  <pre class="lang-java prettyprint-override"><code>ViewGroup.MarginLayoutParams layoutParams = (MarginLayoutParams) image.getLayoutParams ();
  layoutParams.leftMargin = VALUE;
  image.setLayoutParams ( layoutParams );
  </code></pre>
  
  <p>I would like the change in margin to apply with animation. Any clues ?</p>
  
  <p>What I tried :</p>
  
  <pre><code>ObjectAnimator objectAnimator = ObjectAnimator.ofFloat ( image , "x" , VALUE);
  objectAnimator.start();
  </code></pre>
  
  <p>This works perfectly, as the image is moved to the specified X value with animation, <strong>HOWEVER</strong> the value of <strong>layoutParams.leftMargin</strong> remains unchanged !! So I cannot use this method, because if I try to change the value of <strong>layoutParams.leftMargin</strong> to 100 after using the <strong>objectAnimator</strong> with the value 100, the value applied is not correct ( 200 is applied instead of 100, the effect if the <strong>objectAnimator</strong> remains eventhough I am setting the left margin in the following manner :</p>
  
  <pre><code>layoutParams.leftMargin = 100;
  </code></pre>