Alex Rivera | Logout

How to change the position of a progress dialog?

Asked 2010-08-02T22:22:08.287
34

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.

Edit
Report

1 Answer

19

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.

answered 2012-12-24T08:01:17.043

Your Answer