title: Translate Animation for layouts from one position to another in android
body: <p>I have a Linear layout (say A - at top right) inside a FrameLayout. There are some set of new linear layouts created from the code at center bottom &amp; added to the same FrameLayout(say l1,l2,l3...l10). Width &amp; Height of all the layouts (Layout A &amp; 10 new layouts) are same. Hence at center bottom location layout l10 is being shown as its the latest layout added.Remaining layouts will not be shown as they will be behind l10 . Now I want to translate all the 10 layouts from Layout B to Layout A with TranslateAnimation which I am able to do without any issues. </p>
  
  <p>When the first layout(l10) translates from its position to Layout A , it covers the layout A area and i10 will be shown on Layout A now (which is what expected) and l9 will be shown at bottom center location. <strong>BUT</strong> when the next layout(l9) translates layout A , it is going <strong>below</strong>  l10 . Instead it should cover l10 and l9 should be shown on Layout A area now. If anyone has faced this issue before and has any solutions for the same , please share it.</p>
  
  <p>(Have clear screenshots but not able to attach as I am a new member</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong><code>**CODE**</code></strong></p>
  
  <pre><code>int numberOfCardsLeft = 10;
    FrameLayout fl=(FrameLayout)findViewById(R.id.cardsFrameMainLayout);
  
  ArrayList&lt;LinearLayout&gt; animationCardLayouts= new ArrayList&lt;LinearLayout&gt;(10);//used for animation 
  
             for(int i=0;i&lt;10;i++) //create 10 layouts &amp; add to FrameLayout
          {
          cpuPlayers.add(temp.get(i));
          tempCardLayout = new LinearLayout(this);
          layoutParams=new FrameLayout.LayoutParams(cardLayoutWidth,cardLayoutHeight);
          layoutParams.gravity=Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM;
          //layoutParams.leftMargin=0;
          tempCardLayout.setLayoutParams(layoutParams);
          tempCardLayout.setWeightSum(10);
          tempCardLayout.setOrientation(LinearLayout.VERTICAL);
          tempCardLayout.setGravity(Gravity.CENTER);
          //adding different childs &amp; different background to it
          animationCardLayouts.add(tempCardLayout);
          fl.addView(tempCardLayout);
             }
        cardAnimation = new TranslateAnimation("&lt;to fit area of Layout a&gt;");
                  cardAnimation.setFillAfter(true);
                  cardAnimation.setDuration(900);
                  cardAnimation.setAnimationListener(cardAnimationListener);
                  animationCardLayouts.get(numberOfCardsLeft-1).startAnimation(cardAnimation);
  
          cardAnimationListener= new AnimationListener() {
  
          @Override
          public void onAnimationStart(Animation animation) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onAnimationRepeat(Animation animation) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onAnimationEnd(Animation animation) {
              // TODO Auto-generated method stub
              numberOfCardsLeft--;
              if(numberOfCardsLeft!=0)
              {
                  tempCardAnimation = new TranslateAnimation("&lt;to fit area of Layout a&gt;");
                  tempCardAnimation.setFillAfter(true);
                  tempCardAnimation.setDuration(900);
                  tempCardAnimation.setAnimationListener(cardAnimationListener);
                  animationCardLayouts.get(numberOfCardsLeft-1).startAnimation(tempCardAnimation);
              }
          }
      };
  </code></pre>