0

ImageViewAndroid のトゥイーン アニメーションに問題があります。項目を画面の中央から画面の上部に移動しようとしましたが、変換ImageViewが終了すると最初の位置に戻ります! 私はこのコードを使用します:

   <?xml version="1.0" encoding="utf-8"?>
       <translate 
        xmlns:android="http://schemas.android.com/apk/res/android"
         android:interpolator="@android:anim/bounce_interpolator"
         android:fromYDelta="0%"
         android:toYDelta="-1500%"
         android:duration="3000"
         android:startOffset="3000">
         </translate>

private void RunAnimations() {

    Animation animation = AnimationUtils.loadAnimation(this, R.anim.move_up_maxname);
    animation.reset();
    ImageView maxName = (ImageView) findViewById(R.id.imageView1);
    maxName.clearAnimation();
    maxName.startAnimation(animation);
}

誰でも私を助けることができますか?
ありがとう

4

3 に答える 3

3

setFillAfter を確認する必要があります。

fillAfter が true の場合、このアニメーションが実行した変換は、終了後も保持されます。

于 2012-10-05T09:58:15.010 に答える
2

行を追加する animation.setFillAfter(true);

于 2012-10-05T12:08:01.747 に答える
2

AnimationListenerを使用し、onAnimationEnd() で ImageView(Last point) の位置を変更します。

animation.setAnimationListener(new AnimationListener() {

   public void onAnimationStart(Animation anim)
   {};

   public void onAnimationRepeat(Animation anim)
   {};

   public void onAnimationEnd(Animation anim)
   {
     //Change imageview position using LayoutParameters
   };
});                     
于 2012-10-05T09:50:21.277 に答える