4

I want to make a progress bar with a donut shape with rounded edges, looking like this:

enter image description here

I tried this so far:

ProgressBar in XML :

<ProgressBar style="@style/Widget.AppCompat.ProgressBar.Horizontal"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_centerInParent="true"
    android:indeterminate="false"
    android:max="100"
    android:progress="0"
    android:layout_margin="2dp"
    android:progressDrawable="@drawable/shape_ring_gradient"
    android:rotation="-90.0"
    android:visibility="visible"
    android:id="@+id/progress_bar" />

shape_ring_gradient.png :

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadiusRatio="2.17391304"
    android:thicknessRatio="25.0"
    android:useLevel="true">

    <gradient
        android:endColor="#FE000A"
        android:gradientRadius="1000"
        android:startColor="#EB288B"
        android:angle="180"
        android:type="linear" >
    </gradient>

</shape>

Java code:

ProgressBar progressBar = getView().findViewById(R.id.progress_bar);
progressBar.setProgress(82);

Result :

enter image description here

Now my question is, how can I :

  • Make the ring thicker?
  • Round the edges?

Thanks for your help!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Rob
  • 4,123
  • 3
  • 33
  • 53
  • refer this:-https://stackoverflow.com/questions/31219455/android-round-edges-on-ring-shaped-progressbar – Mr. Roshan May 28 '18 at 08:54
  • Got it working playing around with this: https://github.com/korre/android-circular-progress-bar – Rob May 28 '18 at 10:08

0 Answers0