1

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 & added to the same FrameLayout(say l1,l2,l3...l10). Width & Height of all the layouts (Layout A & 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.

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. BUT when the next layout(l9) translates layout A , it is going below 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.

(Have clear screenshots but not able to attach as I am a new member

Thanks in advance.

**CODE**

int numberOfCardsLeft = 10;
  FrameLayout fl=(FrameLayout)findViewById(R.id.cardsFrameMainLayout);

ArrayList<LinearLayout> animationCardLayouts= new ArrayList<LinearLayout>(10);//used for animation 

           for(int i=0;i<10;i++) //create 10 layouts & 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 & different background to it
        animationCardLayouts.add(tempCardLayout);
        fl.addView(tempCardLayout);
           }
      cardAnimation = new TranslateAnimation("<to fit area of Layout a>");
                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("<to fit area of Layout a>");
                tempCardAnimation.setFillAfter(true);
                tempCardAnimation.setDuration(900);
                tempCardAnimation.setAnimationListener(cardAnimationListener);
                animationCardLayouts.get(numberOfCardsLeft-1).startAnimation(tempCardAnimation);
            }
        }
    };
Kalmesh Sam
  • 71
  • 2
  • 10

0 Answers0