How to show a progress dialog without message (I only need the indeterminate circle)?
Asked Answered
W

3

6

How can I show a progress dialog without the message?

I only need to show the indeterminate circle. What is the easiest and fastest way of doing this without creating a custom dialog? Is there any method similar to this:

progressDialog.setShowIndeterminateCircleOnly(true)

Wehner answered 23/11, 2011 at 9:58 Comment(2)
ProgressBar should suffice your requirement !Cunaxa
Well, I can't do anything if that's not what the client wanted.Wehner
S
3

if you need a only spinning wheel without box, you can use like this.

<ProgressBar
       style="?android:attr/progressBarStyle"
       android:layout_gravity="center_horizontal"
       android:id="@+id/progressbar_downloading"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
/>
Silurid answered 23/12, 2011 at 11:20 Comment(2)
Set reference to XML file for your Dialog like... progressDialog.setContentView( R.layout.progress_bar ); This solution still DOES show the box covering parent width.Sandarac
Why this answer is accepted as right one? when question is about only to show progress circle with progress dialog(Not with progress bar).Ty
S
11

Hope this will help some as answer is still not easily found.

ProgressDialog progDialog = ProgressDialog.show( getContext(), null, null, false, true );
progDialog.getWindow().setBackgroundDrawable( new ColorDrawable( Color.TRANSPARENT ) );
progDialog.setContentView( R.layout.progress_bar );

2nd line above will remove the box around the progress Circle icon; but it will stay left aligned by default. You will have to add the third line above to handle gravity and any other style in a XML layout file.

progress_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<ProgressBar
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" />

You do not have to define the style above if you like the default smaller circle Icon

Sandarac answered 22/6, 2016 at 22:38 Comment(0)
S
3

if you need a only spinning wheel without box, you can use like this.

<ProgressBar
       style="?android:attr/progressBarStyle"
       android:layout_gravity="center_horizontal"
       android:id="@+id/progressbar_downloading"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content" 
/>
Silurid answered 23/12, 2011 at 11:20 Comment(2)
Set reference to XML file for your Dialog like... progressDialog.setContentView( R.layout.progress_bar ); This solution still DOES show the box covering parent width.Sandarac
Why this answer is accepted as right one? when question is about only to show progress circle with progress dialog(Not with progress bar).Ty
G
-1

Do only progressbar in your xml file

    <ProgressBar 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

or Create ProgressDialog without setting title

ProgressDialog dialog = ProgressDialog.show(ActivityName.this, "", "", true);
        dialog.setCancelable(true);
Graupel answered 23/11, 2011 at 10:4 Comment(5)
If I do that, there will be an extra space on the right of the circle. The box will still be a rectangle. I want the box to cover only the circle.Wehner
You need to do a custom view for your dialog. The SDK dev guide has examplesJarv
Thank you, it seems I have no choice but to create a custom dialog.Wehner
if u want only moving circle in progress dialog then only way to do custom dialog from xml file and inflate through layoutinflater in java class.u can also set a animated gif image in progressdialog. ThanksGraupel
@android_dev: I tried creating a custom dialog having only the circle but the width of the dialog does not change. How do I make the width smaller?Wehner

© 2022 - 2024 — McMap. All rights reserved.