Shanki Bansal
Shanki Bansal

Reputation: 1750

How to use VectorDrawable as ProgressBar

enter image description here

Is it possible to colour the arc according to the percentage using vector drawable.

Upvotes: 3

Views: 1424

Answers (1)

Shanki Bansal
Shanki Bansal

Reputation: 1750

Got the alternative solution here : Circular ProgressBar in android

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="220dp"
        android:layout_height="220dp"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:max="100"
        android:progress="90"
        android:progressDrawable="@drawable/circular"
        android:rotation="-90" />

    <TextView
        android:id="@+id/TextView_percentage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/progressBar"
        android:layout_alignLeft="@+id/progressBar"
        android:layout_alignRight="@+id/progressBar"
        android:layout_alignTop="@+id/progressBar"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="90%" />

circular.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadiusRatio="2.3"
    android:shape="ring"
    android:thickness="3.8sp"
    android:useLevel="true">
    <solid android:color="@color/colorPrimary" />
</shape>

Upvotes: 1

Related Questions