Android -- custom ProgressDialog display position (Other Dialog subclasses can be set)
1. Generally, the default Dialog display position is centered on the screen:
PbDialog = new ProgressDialog (MainActivity. this); pbDialog. setMessage ("Please wait, loading"); pbDialog. show ();
2. Set the Dialog display position at the bottom of the screen:
PbDialog = new ProgressDialog (MainActivity. this); pbDialog. setMessage ("Please wait, loading"); WindowManager. layoutParams params = pbDialog. getWindow (). getAttributes (); pbDialog. getWindow (). setGravity (Gravity. BOTTOM); pbDialog. show ();
3. Set the Dialog display position at the bottom of the screen and PX from the bottom:
PbDialog = new ProgressDialog (MainActivity. this); pbDialog. setMessage ("Please wait, loading"); WindowManager. layoutParams params = pbDialog. getWindow (). getAttributes (); pbDialog. getWindow (). setGravity (Gravity. BOTTOM); params. y = 100; pbDialog. getWindow (). setAttributes (params); pbDialog. show ();