title: Android translate animation - permanently move View to new position using AnimationListener
body: <p>I have android translate Animation. I have an ImageView with random generated position (next1, next2). I am calling void every 3 seconds. It generates new position of the View and then make animation and move View to destination position. Translate animation has  AnimationListener implemented. When the animation finish,  I move View permanently to the new position (in OnAnimationEnd). My problem is that animation position does not correspond with setting layoutParams positions. When animation end, it makes jump to a new position, which is about 50-100 pixels far. I think the positions should be the same because I use same values (next1, next2) in both situations. Please can you show me the way to find sollution ? <img src="https://i.stack.imgur.com/KTKcf.jpg" alt="Drawing of situation here here"></p>
  
  <pre><code> FrameLayout.LayoutParams pozice_motyl = (FrameLayout.LayoutParams)  pozadi_motyl.getLayoutParams();    
              TranslateAnimation anim = new TranslateAnimation(Animation.ABSOLUTE,pozice_motyl.leftMargin, Animation.ABSOLUTE, next1, Animation.ABSOLUTE, pozice_motyl.topMargin, Animation.ABSOLUTE, next2);
              anim.setDuration(1000);
              anim.setFillAfter(true);
              anim.setFillEnabled(true);
  
              anim.setAnimationListener(new Animation.AnimationListener() {
                  @Override
                  public void onAnimationStart(Animation animation) {
                  }
  
                  @Override
                  public void onAnimationEnd(Animation animation) {
  
  
  
  
                      FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(100, 100);
  
                      layoutParams.leftMargin = (int)(next1);
                      layoutParams.topMargin = (int)(next2);
                      pozadi_motyl.setLayoutParams(layoutParams);
  
                  }
  
                  @Override
                  public void onAnimationRepeat(Animation animation) {
  
                  }
              });
  
              pozadi_motyl.startAnimation(anim);
  </code></pre>
  
  <p>Here is XML layout:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" 
      android:id="@+id/pozadi0"
      android:gravity="center_vertical"
      android:layout_gravity="center_vertical"          
      android:background="@drawable/pozadi2"
      &gt;
  
  
  
  &lt;LinearLayout
  android:id="@+id/pozadi_motyl"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          &gt;
  
    &lt;ImageView android:id="@+id/obrazek_motyl"
               android:src="@drawable/motyl"
               android:layout_width="100dip"
               android:layout_height="100dip"
                           /&gt;
  
     &lt;/LinearLayout&gt;
  
  
  &lt;LinearLayout 
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  &gt;
  
  &lt;RelativeLayout
  android:id="@+id/obrazek_pozadi0"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  &gt;
  
  
  
   &lt;ImageView android:id="@+id/zaba_obrazek0"
  android:src="@drawable/zaba_obrazek"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_alignParentBottom="true"
  android:layout_centerInParent="true"
  /&gt;
  
  &lt;/RelativeLayout&gt;   
  &lt;/LinearLayout&gt; 
  
  &lt;LinearLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" 
  &gt;
  
  &lt;cz.zaba.Spojnice  
  android:layout_width="fill_parent"          
  android:layout_height="fill_parent" 
  /&gt;
  
  &lt;/LinearLayout&gt;
  &lt;/FrameLayout&gt;
  </code></pre>