[英]Progress bar not showing progress swiftly
My progress bar is not going swiftly. 我的进度条进展不快。 Below is my code:
下面是我的代码:
_progressBar.setMax(30);
new CountDownTimer(30000, 100) {
public void onTick(long millisUntilFinished) {
_progressBar.setProgress((int)millisUntilFinished/1000);
time.setText(String.valueOf((int) millisUntilFinished / 1000));
}
public void onFinish() {
}
}.start();
This is my progress bar: 这是我的进度栏:
I'd try using the value animator to ease from 0 to 30. 我会尝试使用值动画器来简化从0到30的设置。
//ease from 0 to 30
ValueAnimator valueAnimator = ValueAnimator.ofInt(0, 30);
//set time length
valueAnimator.setDuration(30000);
//control easing type
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new AnimatorUpdateListener()
{
Integer valueAnimatorValue = null;
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
valueAnimatorValue = (Integer) animation.getAnimatedValue();
_progressBar.setProgress(valueAnimatorValue);
time.setText(String.valueOf(valueAnimatorValue);
}
});
valueAnimator.start();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.