ProgressDialog showing white background dialog with progress inside it - android

I am trying to show a simple progress (indeterminate) to indicate that it is loading.
Here is the code I am using
ProgressDialog progressDiag = new ProgressDialog(this);
progressDiag.setIndeterminate(true);
progressDiag.show();
Where this refers to the current AppCompatActivity
However this is what I am getting
As you can see, it is displaying White dialog with progress bar at the side of it!
Why is the progress circle inside a white dialog, how can I get rid of that or at least make it as big as the progress circle (and in the middle)?
This looks like there is contents missing
Thank you

Use ProgressBar for this
<ProgressBar
android:id="#+id/pb"
android:indeterminate="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
https://developer.android.com/reference/android/widget/ProgressBar.html

Related

Text alignment of progress dialog in Android

I am developing an Android app. In my app , I am showing progress dialog. I can show it very easily. But the problem is as in screenshot below.
As you can see above the circle is aligned to left. I want to center it. I searched solutions online. But all solutions are complicated. For example I have to create custom dialog extending dialog class. But I think it is not worth to do it. Besides, I think android has the built in easy way to do it.
This is my code to show dialog:
public void showLoginLoadingPopUp()
{
loadingDialog = new ProgressDialog(this);
loadingDialog.setTitle("Loading please wait . . .");
loadingDialog.show();
}
As you can see, the code is so simple. I also want simple code to align circle to center of dialog without customizing dialog class.
Example loadingDialog.setTextAlign(center).
But I cannot find any function to do it. What would be the easiest way to do it ?
you have used setTitle() instead of that use setMessage().
public void showLoginLoadingPopUp()
{
loadingDialog = new ProgressDialog(this);
loadingDialog.setMessage("Loading please wait . . .");
loadingDialog.show();
}
Thats it.
Progress dialog can be upgraded with custom layout, which displays required result
ProgressDialog progressDialog = ProgressDialog.show(this, null, null, true, false);
progressDialog.setContentView(R.layout.progress_layout);
And with layout XML file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ProgressBar
android:id="#+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
Hope this helps!!!

Custom progress dialog

How would I do a custom "loading" dialog during an AsyncTask like the one in the Bank of America app, for instance? See:
I basically don't want the popup ProgressDialog but instead one that is embedded into the layout.
It's not a ProgressDialog. It's just a ProgressBar. Put it on your layout and make it visible when it's necessary.
That's a ProgressBar view that can be added to any layout:
<ProgressBar
android:indeterminate="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>

Android; A progressbar with a custom dialog

I've have a custom dialog displaying a splash screen;
mSplashDialog = new Dialog(MyActivity.this,R.layout.splash);
mSplashDialog.setContentView(R.layout.splash);
mSplashDialog.setCancelable(true);
mSplashDialog.show();
The splash layout has a ProgressBar on it;
LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="#drawable/picture_splash"
ProgressBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:id="#+id/progressbar_Horizontal"
android:max="100"
LinearLayout
But when I try to reference to the progress bar;
progress = (ProgressBar) findViewById(R.id.progressbar_Horizontal);
progress.setMax(100);
I've found out in the debugger that the app crashes on the second line because the object progress = null, empty zipp, nuttin :(
It seems like that the progressbar, once docked in a dialog is not accessable... :(
Somebody knows a way around this?
A ProgresDialog is not a option, because you can't customize it...
Thanks guys!
Check that you are invoking findViewById() in the correct context. For example, what you currently have is equivalent to:
progress = (ProgressBar)this.findViewById(R.id.progressbar_Horizontal);
If mSplashDialog is not part of the view hierarchy for "this", then findViewById will never find your progressBar. Perhaps you want something like:
progress = (ProgressBar)mSplashDialog.findViewById(R.id.progressbar_Horizontal);

Understanding android dialog layouts

I'm making a simple custom dialog for my android app, displaying only a seek bar. However, the complications of this simple task are driving me nuts.
My layout for the dialog is as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp">
<SeekBar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/dialogVolumeSlider"
android:layout_width="225dp"
android:layout_height="wrap_content"/>
</LinearLayout>
The dialog is created in code:
Dialog d = new Dialog(this);
d.setContentView(R.layout.custom_dialog);
return d;
Instead of a simple box wrapping the seekbar, I get this phantom space coming from somewhere:
What's the issue here? I've tried modifying
d.getWindow().getAttributes().height
but this creates additional problems as well.
Thanks for any help!!
EDIT: Stranger things happen when I assigned a fixed "50dp" to my LinearLayout's layout_height:
By default a Dialog will leave space for a title even if you don't set one (with d.setTitle()) .
You can either set a title to fill the space or request that the Dialog not have a title.
Here is an example of how to request the no title setting.
Dialog d = new Dialog(this);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(R.layout.custom_dialog);
With no title, your SeekBar will appear as you expect.
Try putting a fixed Height on your parent linear layout. Something like:
android:layout_height="50px"

Android: Show progress circle like Google does in their apps

I'm using an AsyncTask to download Images for my Listview, because I dont want the download of the Images to block my UI-Thread. While the images are being loaded, I want to show an animated progress circle in the spot, where the image will be.
But I cant find an Image of the progress circle. What is the Ressource-Id? Or is there any other way? Does someone has a link to this image?
Look at the progress bar. It can work (and it does by default, AFAIR) in indeterminate mode, which means it shows a rotating circle, like the one you are asking for. I know this is not an image, but what you can do, is to place a FrameLayout instead of the image, with progress bar as the only child. Then, once the loading of the images finishes, remove the progress bar and add the image.
Define this a global variable ProgressDialog pd;
Just before launche the AsyncTask do:
pd = ProgressDialog.show(CurrentClassName.this,"This is the title","This is the detail text",true,false,null);
When its done onPostExecute just call pd.dismiss();
For more detail look at : ProgressDialog
You will have to take special considerations for it to work when you rotate the device while the dialog is up.
This is an example of a layout file for intro activity with an image and circle progress bar:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/intro_description"
android:scaleType="fitXY"
android:src="#drawable/intro" />
<ProgressBar
android:id="#+id/progress"
style="?android:attr/progressBarStyleInverse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="150dp"
android:visibility="visible" />
</FrameLayout>
You want an indeterminate ProgressBar. Take a look at developer's website -
ProgressBar

Categories

Resources