4

I have the mic icon and surrounding the mic icon, I need to place the Progress Bar to handle some running process like below:

<ImageView android:id="@+id/iv_mic_movable" android:layout_width="60dp" android:layout_height="60dp" android:layout_gravity="center_horizontal" android:layout_marginTop="68dp" android:src="@drawable/record" /> <ProgressBar android:id="@+id/pb_assist" style="?android:attr/progressBarStyleLarge" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center_horizontal" android:layout_marginTop="53dp" android:visibility="gone" /> 

The above code shows the UI as follows:

enter image description here

I want to show the progress bar like this, But this progress is very Thick. How to make it somewhat thinner with only 1dp?

2

4 Answers 4

11

None of the above answers worked for me. Struggling around found a below working solution.

progressbar_circular.xml. Use android:thicknessRatio for thickness of the circle. More the value will be, thinner it will be.

<?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:duration="0" android:toDegrees="360" > <shape android:innerRadiusRatio="3" android:shape="ring" android:thicknessRatio="40" android:useLevel="false" > <size android:height="48dip" android:width="48dip" /> <gradient android:centerColor="@color/colorPrimary" android:centerY="0.50" android:endColor="@color/color_black" android:startColor="@color/colorPrimary" android:type="sweep" android:useLevel="false" /> </shape> </rotate> 

Progress bar layout will be like below:

<ProgressBar android:id="@+id/progressBar" android:layout_width="match_parent" android:layout_height="match_parent" style="?android:attr/progressBarStyleLarge" android:indeterminateDrawable="@drawable/progressbar_circular" android:layout_gravity="center_horizontal" android:visibility="visible"/> 
Sign up to request clarification or add additional context in comments.

1 Comment

Hi where did you get this info from ?? I would like to get information about this doc please
3

Here is custom ProgressBar. You can set thickness of progress inside shape.

<ProgressBar style="?android:attr/progressBarStyleHorizontal" android:layout_width="172dp" android:layout_height="172dp" android:indeterminate="false" android:max="100" android:visibility="visible" android:progress="0" android:layout_gravity="center_horizontal" //updated line android:layout_marginTop="53dp" //updated line android:background="@drawable/circle_shape" android:progressDrawable="@drawable/circle_progress_foreground" /> 

circle_shape.xml

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="ring" android:innerRadiusRatio="2.2" android:thickness="5dp" android:useLevel="false"> <solid android:color="#ABBAC2" /> </shape> 

circle_progress_foreground.xml

Change android:thickness as per your requirement

<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:fromDegrees="270" android:toDegrees="270"> <shape android:innerRadiusRatio="2.7" android:shape="ring" android:thickness="2dp" android:useLevel="true"> <solid android:color="#fbcb09" /> </shape> </rotate> 

2 Comments

I tried your code. The result is not as per the requirement. The progress is not running. It is appearing in the left most position.
it's an idea, you can achieve like this.you have to change alignment of progressbar. see update answer!
0

You can also achieve this by adding mimimum width and height

<ProgressBar android:id="@+id/progressBar1" style="?android:attr/progressBarStyleHorizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="23dp" android:layout_marginTop="20dp" android:indeterminate="false" android:max="100" android:minHeight="5dp" android:minWidth="200dp" android:progress="1" /> 

Comments

0

try to add this below style on your xml progessBar layout,

 style="@android:style/Widget.ProgressBar.Large.Inverse" 

Update

try to add this property:

android:progressDrawable="@android:drawable/progress_horizontal" 

5 Comments

I tried but it is giving some different progress bar then my requirement. So I tried style="?android:attr/progressBarStyleLargeInverse". But the result was same. I also tried setting fixed dp to wrap content, But then progress bar is not setting exactly around the image.
I need to make the progress bar looks thinner. It is very thick.
so you need thinker line progress in progressbar. right?
Yes thinner line progress
have you tried maxHeight and minHeight as property of progressBar?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.