0

I am creating an animation in which an image translate from one direction to another, animation moves half of the image out side the screen but image shows full when animation ends. I just want to show half of the image after animation.

Currently I am using full image in the image view when animation starts and replace it with the half image when animation ends but it shows an image change reflection which looks awkward which is my actual problem.

Below is my xml and class file.

animation code

<translate xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration = "2000"
    android:fillBefore="true"
    android:fillEnabled="true"
    android:fromXDelta = "-300%"
    android:fromYDelta="200%"
    android:toXDelta="60%">

</translate>

animimv5.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                imv5.setBackgroundResource(R.drawable.img5);
            }
            @Override
            public void onAnimationRepeat(Animation animation) {

            }
            @Override
            public void onAnimationEnd(Animation animation) {
                imv5.setBackgroundResource(R.drawable.img5_2);
            }
        });
4

2 に答える 2

1

次のことを試してみてください。

xmlで(パラメータを設定するために追加する)android:fillAfter、またはクラスソースで関連するメソッドを使用するsetFillAfter(boolean)

true に設定すると、アニメーションの終了後にアニメーション変換が適用されます。ここのドキュメントによると 、true に設定すると、アニメーションの終了後にアニメーション変換が適用されます。デフォルト値は false です。fillEnabled が true に設定されておらず、アニメーションがビューに設定されていない場合、fillAfter は true と見なされます。

追加のヒントと説明については、Chet のブログ投稿を確認してください

それが役に立てば幸い.. ;)

于 2013-09-03T07:06:16.647 に答える