自定义循环进度条

时间:2018-09-27 07:09:23

标签: android progress-bar

我能够创建一个通告ProgressBar来显示我的进度。

enter image description here

此进度条将从顶部中心点开始,并从右向左移动。

但是现在我需要对其进行修改以使其看起来像下面的图像。

enter image description here

ProgressBar不再是一个完整的圆圈,而是将为文本显示留出足够的空间,并从左下到右开始。

我如何做到这一点?

1 个答案:

答案 0 :(得分:3)

您正在搜索lzyzsd/CircleProgress库。

<com.github.lzyzsd.circleprogress.ArcProgress
    android:id="@+id/arc_progress"
    android:background="#214193"
    android:layout_marginLeft="50dp"
    android:layout_width="100dp"
    android:layout_height="100dp"
    custom:arc_progress="55"
    custom:arc_bottom_text="MEMORY"/>

image

您可以通过属性对其进行自定义。

<declare-styleable name="ArcProgress">
    <attr name="arc_progress" format="integer"/>
    <attr name="arc_angle" format="float"/>
    <attr name="arc_stroke_width" format="dimension"/>
    <attr name="arc_max" format="integer"/>
    <attr name="arc_unfinished_color" format="color"/>
    <attr name="arc_finished_color" format="color"/>
    <attr name="arc_text_size" format="dimension"/>
    <attr name="arc_text_color" format="color"/>
    <attr name="arc_suffix_text" format="string"/>
    <attr name="arc_suffix_text_size" format="dimension"/>
    <attr name="arc_suffix_text_padding" format="dimension"/>
    <attr name="arc_bottom_text" format="string"/>
    <attr name="arc_bottom_text_size" format="dimension"/>
</declare-styleable>

访问github page进行更多自定义。