我用一个进度条(巴形式)。我希望做酒吧的增加和使用插平稳下降,但它不工作。这是我目前所面对的:
I'm using a progress bar (in bar form). I wish to make the bar increase and decrease smoothly using an interpolator, but It's not working. This is what I have at the moment:
pb.setInterpolator(main.this, android.R.anim.bounce_interpolator);
pb.setProgress(pb.getProgress()+10);
我做得真的错了?
Am I doing something really wrong?
插补器已经被连接到了动画,这将工作仅在蜂窝或更高:
The Interpolator have to be attached to an animation and this will work only on Honeycomb or higher :
if(android.os.Build.VERSION.SDK_INT >= 11){
// will update the "progress" propriety of seekbar until it reaches progress
ObjectAnimator animation = ObjectAnimator.ofInt(seekbar, "progress", progress);
animation.setDuration(500); // 0.5 second
animation.setInterpolator(new DecelerateInterpolator());
animation.start();
}
else
seekbar.setProgress(progress); // no animation on Gingerbread or lower
如果您的最低SDK是姜饼或更低时,添加
If your minimum SDK is Gingerbread or lower, add
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
// or
@SuppressLint("NewApi")
你的函数/类。
to your function/class.
我用了DecelerateInterpolator,但这是可选的,还有其他的可能性。
I used a DecelerateInterpolator, but this is optional and there are others possibilities.