When I add horizontal ProgressBar it behaves as expected -- I set the progress value and it shows it.
However when I add ProgressBar (circular) it spins. And that's it. In such form it is more "please wait" indicator, that any progress bar, because progress value is not shown.
So my question is (assuming Progress in name means progress) -- how to stop spinning and shows progress value? For example if I set max to 100, and value to 50 I would expect to see half-circle arc.
In other words how to make circular ProgressBar to behave like horizontal ProgressBar, with only exception of the shape?
You want to stop the progressDialog or change its UI not to be circular? You can set your progressbar's visibility to invisible or gone through progressbar. setVisibility(View. INVISIBLE); or progressBar.
Android ProgressBar Indeterminate ProgressBar An indeterminate ProgressBar shows a cyclic animation without an indication of progress.
In Android, SeekBar is an extension of ProgressBar that adds a draggable thumb, a user can touch the thumb and drag left or right to set the value for current progress. SeekBar is one of the very useful user interface element in Android that allows the selection of integer values using a natural user interface.
I know that this is an old post but I ran into the same issue and I make it work.
It is actually easier than you think, you have to set a custom progress in an xml file inside your drawable folder and handle the attributes "fromDegrees" and "toDegrees" from the < rotate > tag:
This is the code for custom_progress.xml (you can customize yours as you like but you must not modify "fromDegrees" and "toDegrees")
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background"> <shape android:innerRadiusRatio="2.3" android:shape="ring" android:useLevel="false" android:type="sweep" android:thicknessRatio="15.0"> <solid android:color="#0099ff"/> </shape> </item> <item android:id="@android:id/progress"> <rotate android:pivotX="50%" android:pivotY="50%" android:fromDegrees="-90" android:toDegrees="-90"> <shape android:innerRadiusRatio="2.3" android:shape="ring" android:angle="0" android:type="sweep" android:thicknessRatio="15.0"> <solid android:color="#e0e0e0"/> </shape> </rotate> </item> </layer-list>
And for your progress bar you have to set this attributes:
<ProgressBar android:id="@+id/progressbar" style="?android:attr/progressBarStyleHorizontal" android:layout_width="100dp" android:layout_height="100dp" android:indeterminate="false" android:max="100" android:progress="20" android:progressDrawable="@drawable/custom_progress" />
What is happening here is that the progress will start in degree -90 which for me is the top side of the progress bar view and towards the right and it will continue towards the same degree, this will make the view progress to start and end in the same degree.
NOTE: If you set 0 for both "fromDegrees" and "toDegrees" the progress will start from the right side of the circle.
Hope it helps people with the same requirement.
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