Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the position of a progress dialog?

I'm developing an android app and need to know how to change the positioning of a progress dialog. I need it to be positioned at the bottom of the screen instead of at the center like it is by default.

like image 315
oliverwhite Avatar asked Aug 02 '10 22:08

oliverwhite


People also ask

What can I use instead of progress dialog?

ProgressBar is best alternative for ProgressDialog.

What is progress dialog in Android?

ProgressDialog is a modal dialog, which prevents the user from interacting with the app. Instead of using this class, you should use a progress indicator like ProgressBar , which can be embedded in your app's UI. Alternatively, you can use a notification to inform the user of the task's progress.


2 Answers

You can call ProgressDialog#getWindow#setGravity(...) to change the gravity.

So:

ProgressDialog dialog = ProgressDialog.show(AContext, "Test", "On the bottom");                 dialog.getWindow().setGravity(Gravity.BOTTOM); 
like image 56
Rich Schuler Avatar answered Sep 22 '22 23:09

Rich Schuler


In addition to the other answers you can use LayoutParams.x or LayoutParams.y to provide an offset from the given edge. For Example:

progressDialog = ProgressDialog.show(this, "Title","Text");  progressDialog.getWindow().setGravity(Gravity.TOP); LayoutParams params = progressDialog.getWindow().getAttributes(); params.y = 100; progressDialog.getWindow().setAttributes(params); 

And it is good for you to know about LayoutParams.y:

Y position for this window. With the default gravity it is ignored. When using TOP or BOTTOM it provides an offset from the given edge.

and about LayoutParams.x:

X position for this window. With the default gravity it is ignored. When using LEFT or START or RIGHT or END it provides an offset from the given edge.

like image 29
Bobs Avatar answered Sep 22 '22 23:09

Bobs