动画搜索栏进度

Rav*_*yas 12 animation android seekbar

我有一个带有4个搜索条的屏幕(如下图所示).如果用户移动B,C或DI,则将A的平均值和A的setProgress计算为平均值.这很容易.我想要做的是为进度条A设置动画,使其不会一次跳转(例如从25-75).

有什么建议的动画A方式?我得到了一个简单的动画,但我每隔50ms调用一次TimerTask,以A为单位增加或递减A,直到达到所需位置.但它效率不高.

注意:我有一个自定义的Seekbar对象,我使用它创建了seekBar的A,B,C和D.抱歉,我不能真正分享代码,但很乐意澄清任何内容.

在此输入图像描述

小智 15

我猜它为时已晚.但我找到了一种使用ValueAnimator实现这一目标的方法.

ValueAnimator anim = ValueAnimator.ofInt(0, seekBar.getMax());
anim.setDuration(1000);
anim.addUpdateListener(new AnimatorUpdateListener() {
    @Override
    public void onAnimationUpdate(ValueAnimator animation) {
    int animProgress = (Integer) animation.getAnimatedValue();
    seekBar.setProgress(animProgress);
    }
});
anim.start();
Run Code Online (Sandbox Code Playgroud)


ilb*_*ose 5

我已经使用ObjectAnimator.

private void animateProgression(int progress) {
    final ObjectAnimator animation = ObjectAnimator.ofInt(mySeekBar, "progress", 0, progress);
    animation.setDuration(3000);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.start();
    mySeekBar.clearAnimation();
}
Run Code Online (Sandbox Code Playgroud)


Rav*_*yas -1

我通过指数函数而不是单位增量迭代计时器任务来减少迭代次数。仍然希望得到更好的答案:-)