1

FrameLayout 内に Linear レイアウト (たとえば A - 右上) があります。中央下部のコードから作成され、同じ FrameLayout (l1、l2、l3...l10 など) に追加された新しい線形レイアウトのセットがいくつかあります。すべてのレイアウト (レイアウト A と 10 個の新しいレイアウト) の幅と高さは同じです。したがって、中央下部の場所のレイアウト l10 は、追加された最新のレイアウトとして表示されています。残りのレイアウトは l10 の後ろに表示されるため、表示されません。ここで、10 個のレイアウトすべてをレイアウト B からレイアウト A に TranslateAnimation を使用して変換したいと考えています。これは問題なく実行できます。

最初のレイアウト (l10) がその位置から Layout A に変換されると、レイアウト A 領域がカバーされ、i10 がレイアウト A に表示され (これが予想されます)、l9 が下部中央の位置に表示されます。しかし、次のレイアウト(l9)がレイアウト A を変換すると、 l10 を下回ります 。代わりに、l10 をカバーし、l9 をレイアウト A エリアに表示する必要があります。以前にこの問題に直面したことがあり、同じ解決策がある場合は、共有してください。

(鮮明なスクリーンショットがありますが、私は新しいメンバーなので添付できません)

前もって感謝します。

**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);
            }
        }
    };
4

0 に答える 0