【问题标题】:Create a custom circular progress bar [closed]创建自定义圆形进度条 [关闭]
【发布时间】:2015-10-30 16:57:31
【问题描述】:

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

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

谢谢!

【问题讨论】:

    标签: android android-view android-support-library android-progressbar


    【解决方案1】:

    在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 并在您想要的任何地方使用。

    【讨论】:

    • 我不能让它工作,我应该为图像视图设置背景吗?
    • ..对于我之前的评论,这就是答案
    • 您的图像是否像进度条一样旋转?如果是,那么由您决定如何自定义它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多