TranslateAnimation处于反向位置?

时间:2015-05-13 12:23:37

标签: android translate-animation

我正在使用TranslateAnimation的app,但我想将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);
}

2 个答案:

答案 0 :(得分:6)

尝试使用此代码

<name>: initial

答案 1 :(得分:1)

使用Interpolator for Like,

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());