I have a default progress bar

For me it's very large border. How can I make a progress bar like this (with thin border)?

I have a simple layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ProgressBar
android:id="@+id/hello_progress_bar"
android:layout_width="210dp"
android:layout_height="210dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Create a file with shape drawable for your progress
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360">
<shape
android:innerRadiusRatio="3"
android:shape="ring"
android:thicknessRatio="8"
android:useLevel="false">
<solid
android:color="#F3A523"/>
</shape>
</rotate>
Use it inside your ProgressBar
<ProgressBar
android:id="@+id/progress_bar"
android:layout_width="24dp"
android:layout_height="24dp"
android:indeterminate="true"
android:progressDrawable="@drawable/progress_bar"
android:indeterminateDrawable="@drawable/progress_bar"
/>
This way you can control width of your border via thicknessRatio property of the drawable

1> Create a Drawable for Ring Progressbar progressbar.xml and put into drawabal folder.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/progress">
<rotate android:toDegrees="360">
<shape
android:shape="ring"
android:thickness="4dp"
android:innerRadiusRatio="3"
android:thicknessRatio="20.0">
<solid android:color="#FF4081" />
</shape>
</rotate>
</item>
</layer-list>
2> Set above Drawable into your progressbar
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ProgressBar
android:id="@+id/hello_progress_bar"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:progressDrawable="@drawable/progressbar"
android:indeterminateDrawable="@drawable/progressbar"
/>
</android.support.constraint.ConstraintLayout>
Set below properties in drawable file
android:innerRadiusRatio="3"
android:thicknessRatio="20.0
Hope this may help you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With