创建自定义循环进度条

Create a custom circular progress bar

我想创建一个应如下所示的自定义圆形进度条:

但我不想使用库,它需要支持 api 9 级及以上。谁能告诉我该怎么做?

谢谢!

ImageView 中设置图像并执行此操作。

loadingIcon = (ImageView) findViewById(R.id.splash_loader);
RotateAnimation anim = new RotateAnimation(0.0f, 360.0f,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(500);
loadingIcon.startAnimation(anim);

当你需要停止它时这样做

loadingIcon.setAnimation(null);

注意:如果您需要在多个地方使用它,请创建一个使用此代码扩展 ImageView 的自定义视图,并在您想要的任何地方使用。