9

この奇妙な問題が発生しています。基本的に、翻訳アニメーションでビューをアニメーション化しています。(2つの異なるイベントを介して画面に変換し、出力します)翻訳アニメーションの私のコードは次のとおりです。

    final Animation  animtopOut = new TranslateAnimation(0, 0, 0, -mainHeaderlayout.getMeasuredHeight());
                    animtopOut.setDuration(500);
                    animtopOut.setFillAfter(true);
mainHeaderlayout.setAnimation(animtopOut);

xml コードは次のとおりです。

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillAfter="true"
    android:interpolator="@android:anim/accelerate_interpolator" >

<translate 
    android:fromYDelta="0%p"
    android:toYDelta="-99%p"
    android:duration="600"
    android:fillAfter="true">

</translate>
</set>

コードを使用して設定します。

final Animation animtopOut = AnimationUtils.loadAnimation(mContext, R.anim.header_animate_out);

アニメーションをトリガーすると、xml アニメーション プロパティを使用すると正常に動作します。問題は、コードで使用する場合です。それが私が欲しいものです。初回のみ翻訳アニメーションで動作します。2 回目にトリガーされると、ビューはアニメーションなしで画面内に表示されます。プロパティが不足している場合は、誰か助けてください。ありがとう。


編集:(追加情報)

実際には、2 つの異なるイベントを介して同じビューでトリガーされる 2 つの異なるアニメーションがあります。私は実際に 1 つのアニメーション プロパティを投稿しました。他はほぼ同じです。値が異なるだけです。

4

1 に答える 1

4

このようなアニメーション構成を試しましたか

animtopOut.setRepeatCount(Animation.INFINITE);

animtopOut.setRepeatMode(Animation.RESTART);

animtopOut.setInterpolator(new LinearInterpolator());

?

于 2012-07-02T16:47:20.157 に答える