Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)

like image 442
Arci Avatar asked Nov 23 '11 09:11

Arci


1 Answers

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

like image 68
EMalik Avatar answered Sep 28 '22 11:09

EMalik