TranslateAnimation 处于相反位置?

TranslateAnimation in reverse position?

我正在开发使用了 TranslateAnimation 的应用程序,但我想将 TranslateAnimation 反转到开始位置。

    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        setContentView(R.layout.imageviewactivity);

        TranslateAnimation toptranslateanimation = new TranslateAnimation(0, 0, tempBar,
                    scanner_image.getHeight() - 50);
        toptranslateanimation.setDuration(4000);
            toptranslateanimation.setAnimationListener(this);
                scanning_bar.setAnimation(toptranslateanimation);
}

为点赞使用插值器,

package com.example.android;

import android.view.animation.Interpolator;

public class ReverseInterpolator implements Interpolator {
    @Override
    public float getInterpolation(float paramFloat) {
        return Math.abs(paramFloat -1f);
    }
}

然后在你的动画上你可以设置你的新插值器:

toptranslateanimation.setInterpolator(new ReverseInterpolator());

尝试使用此代码

toptranslateanimation.setRepeatCount(1);
toptranslateanimation.setRepeatMode(Animation.REVERSE);