6

プロジェクトのアニメーションで奇妙な問題が発生しています。以下に投稿されたスクリーンショットでは、Totals カードがアニメーション時に何らかの痕跡を残していることがはっきりとわかります。この問題は、4.2.2 を実行している在庫の Nexus 7 で再現可能です。合計カードには、Google Now スタイルのアニメーションがあります。合計カードのコンテナーはフラグメントであり、横向きのスクリーンショットの左側にあるメニューは別のフラグメントであり、下部のボタンはフラグメントが接続されているアクティビティの一部であることに注意することが重要です。

横向きのスクリーンショット

縦長のスクリーンショット

オンラインで解決策が見つからないようです。 setFillAfter"true" を試し、アニメーションの開始をオフセットしました。ボタンの 1 つが押されると、一番下のアクティビティのボタン (「前へ」と「次へ」) の軌跡が消えます。

Totals Fragment の onCreateView のコードは次のとおりです。

    final View view = inflater.inflate(R.layout.fragment_totals,
            container, false);      

    Fonts.setRobotoThinFont(getActivity(), view);

    final LinearLayout mContainer = (LinearLayout)
            view.findViewById(R.id.container);

    final View mCard = inflater
            .inflate(R.layout.view_simpletotal, mContainer, false);

    Animation animation = AnimationUtils.loadAnimation(getActivity(),
            R.anim.card_animation);

    mContainer.addView(mCard);

    mCard.startAnimation(animation);  

    return view;

どんな助けでも大歓迎です!

4

2 に答える 2

4

アニメーションの終了時にコンテナー アクティビティを無効にするだけで、簡単に取り除くことができます。

于 2013-05-11T23:16:13.307 に答える
3

クラスsetLayoutAnimation()のメソッドを使用することをお勧めします。ViewGroup役立つと思います。
たとえば、フラグメント クラス内に次のコードを記述できます。

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ...
    rootView.setLayoutAnimation(getLayoutAnimation());
    ...
}
private LayoutAnimationController getLayoutAnimation() {
    Animation animation = new RotateAnimation(30, 0, -100, 0);
    animation.setDuration(1000);
    LayoutAnimationController layoutAnimationController = new LayoutAnimationController(animation);
    return layoutAnimationController;
}

アニメーションで何が起こるかを見てください。

于 2013-05-11T23:30:48.607 に答える