2012-04-18 10 views
11

私のアプリでイメージを回転させます。 すべてRotationでうまく動作します。 しかし、私は回転アニメーションが終了する前に、イメージは元の位置に戻ります。私はその回転した状態にそのイメージを残し、それを実際の状態に戻さないようにしたい。Android:アニメーションを回転させた後、アニメーションを回転させて実際の状態に戻しますか?

どうすれば可能になるのですか? 私はコードの下に使用していた画像を回転するには:だから、

myImageView.startAnimation(rotateRight); 

これに関して、私を助けて:

<?xml version="1.0" encoding="utf-8"?> 

<rotate xmlns:android="http://schemas.android.com/apk/res/android" 
    android:pivotX="50%" 
    android:pivotY="50%" 
    android:fromDegrees="0" 
    android:toDegrees="30" 
    android:duration="2000"> 

</rotate> 

などImgeViewにそれを適用します。

答えて

24

はそれだけで、それをアニメーション化、アニメーション表示の実際の特性を変化させていない、<setタグインサイドHow can I animate a view in Android and have it stay in the new position/size?

は、一般的に

android:fillAfter="true" 
android:fillEnabled="true" 

を使用して参照してください。実際のプロパティを変更する場合は、AnimationListenerを使用してonAnimationEndをリッスンし、変更を自分で行います。

+0

よろしくお願いします。 –

+0

私はその仕事だと思います。 –

+1

この属性は必要ありません:android:fillEnabled = "true"この属性には、android:fillBeforeが必要です。 https://developer.android.com/reference/android/view/animation/Animation.html#attr_android:fillAfterをご覧ください。 – Arash

2

まず

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

「R.anim.animation」を使用したアニメーションのインスタンスを取得するには、アニメーションが何であれを指します。

このアニメーションにアニメーションリスナーを使用してください。

anim.setAnimationListener 

ビューをAnimationListenerのonAnimationCompleted()メソッドで表示できるようにします。

これは動作するはずです。

2

setFillAfterとsetFillEnableが必要な回答です。

関連する問題