1

I want to create circular progress bar that shows progress of file uploading and downloading as whats app shows. I have seen number or libraries available on github. I do know this question has been asked and I have gone through those as well as mentioned in below link.

https://github.com/lzyzsd/CircleProgress
https://stackoverflow.com/questions/37238185/how-to-create-a-circularprogressbar-like-whatsapp-during-image-uploading

But above links refer to library. Is there any way to create circular progress bar without using any library?

In one of the link over stackoverflow I found below code

    ObjectAnimator animation = ObjectAnimator.ofInt (progressBar, "progress", 0, 500); 
    animation.setDuration (5000); 
    animation.setInterpolator (new DecelerateInterpolator());

But above code does not set progress dynamically. Means that progress bar works for 5 seconds. It is not mandatory that progress bar should always run for 5 seconds. File size can be vary so is progress bar. My question is how Can I make circular progress bar dynamically without using library?

Anil
  • 1,087
  • 1
  • 11
  • 24

4 Answers4

0

Hope this will help you

layout Xml

<ProgressBar
   android:id="@+id/progressBar"
   style="?android:attr/progressBarStyleHorizontal"
   android:layout_width="150dp"
   android:layout_height="150dp"
   android:layout_alignParentBottom="true"
   android:layout_centerHorizontal="true"
   android:max="500"
   android:progress="0"
   android:progressDrawable="@drawable/circular" />

Now create the drawable in your resources with the following shape. Play with the radius (you can use innerRadius instead of innerRadiusRatio) and thickness values.

<shape
    android:innerRadiusRatio="2.3"
    android:shape="ring"
    android:thickness="3.8sp" >
    <solid android:color="@color/yourColor" />

KeLiuyue
  • 8,149
  • 4
  • 25
  • 42
Azim Shaikh
  • 589
  • 6
  • 18
0

use this link to dynamically create circular progress bar How to Create a circular progressbar in Android which rotates on it? or How to create circular ProgressBar in android?

Mahesh Gawhane
  • 348
  • 3
  • 20
0

You can do that by following way when image view holds from server it hides progress bar until file loads from sever the progress bar rotates.

           <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <ProgressBar
                    android:id="@+id/progress"
                    android:visibility="visible"
                    style="?android:attr/progressBarStyleLarge"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:maxHeight="55dip"
                    android:minHeight="35dip"
                    android:minWidth="55dip"
                    android:maxWidth="10dip"
                    android:layout_centerVertical="true"
                    android:layout_centerHorizontal="true" />

                 <ImageView
                    android:id="@+id/image"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:visibility="visible"/>
            </RelativeLayout>
Muzammil Husnain
  • 1,218
  • 1
  • 10
  • 24
-1

1.use this library may be it help you out:

https://github.com/CardinalNow/Android-CircleProgressIndicator

  1. you can also try this one:

Show Progress bar while downloading

Deepak Rana
  • 539
  • 4
  • 18