PIPIONE
自己创建这个很容易在您的布局中包含以下ProgressBar具有特定可绘制的内容(请注意,您应该从尺寸中获取宽度)。最大值在这里很重要:
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:max="500"
android:progress="0"
android:progressDrawable="@drawable/circular" />现在使用以下形状在资源中创建drawable。使用半径(您可以使用innerRadius而不是innerRadiusRatio)和厚度值进行游戏。循环(Pre Lollipop OR API Level <21)
android:innerRadiusRatio="2.3"
android:shape="ring"
android:thickness="3.8sp" >
圆形(> = Lollipop OR API Level> = 21)android:useLevel="true"
android:innerRadiusRatio="2.3"
android:shape="ring"
android:thickness="3.8sp" >
默认情况下,API Level 21(Lollipop)中的useLevel为“false”。开始动画在代码中接下来使用an ObjectAnimator来ProgessBar为布局的progress字段设置动画。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 valueanimation.setDuration(5000); // in millisecondsanimation.setInterpolator(new DecelerateInterpolator());animation.start();停止动画progressBar.clearAnimation();PS不同于上面的例子,它给出了流畅的动画。