How to make Circular Determinate ProgressBar in Android

Full project with source code to make Circular Determinate ProgressBar in Android

Table of Contents

activity_main.xml

<?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="tech.codingpoint.circulardeterminateprogressbarexample.MainActivity">

    <ProgressBar
        android:layout_width="150dp"
        android:layout_height="150dp"
        style="?android:progressBarStyleHorizontal"
        android:progress="80"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:progressDrawable="@drawable/circle"/>

</android.support.constraint.ConstraintLayout>

circle.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="ring"
    android:innerRadiusRatio="2.5"
    android:thickness="4dp"
    android:useLevel="true">

    <solid android:color="@color/colorAccent" />

</shape>

Leave a Comment