ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", 0, 500); // see this max value coming back here, we animate towards that value
animation.setDuration(5000); // in milliseconds
animation.setInterpolator(new DecelerateInterpolator());
animation.start();
2 回答
你可以尝试这个Circle Progress库
NB: 请始终为进度视图使用相同的宽度和高度
DonutProgress:
CircleProgress:
ArcProgress:
It's easy to create this yourself
在您的布局中包含以下具有特定drawable的
ProgressBar
(请注意,您应该从尺寸中获取宽度) . 最大值在这里很重要:现在使用以下形状在资源中创建drawable . 使用半径(您可以使用
innerRadius
而不是innerRadiusRatio
)和厚度值进行游戏 .circular (Pre Lollipop OR API Level < 21)
circular ( >= Lollipop OR API Level >= 21)
默认情况下,API Level 21(Lollipop)中的useLevel为 "false" .
Start Animation
在代码中接下来使用
ObjectAnimator
来为布局的ProgessBar
的进度字段设置动画 .Stop Animation
附:与上面的例子不同,它提供了流畅的动画