【问题标题】:TranslateAnimation in reverse position?TranslateAnimation 在反向位置?
【发布时间】:2017-08-02 23:32:46
【问题描述】:

我正在开发使用 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);
}

【问题讨论】:

标签: android translate-animation


【解决方案1】:

尝试使用此代码

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-26
      • 1970-01-01
      • 2012-01-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多