dialog is displayed by default in the middle, to be displayed in other locations, use the following method to implement
private void ShowDialog () {
Alertdialog Mdialog = new Alertdialog.builder (this)
. SetIcon (R.drawable.ic_launcher). Settitle ("Warm Tips")
. Setmessage ("Transparent dialog box")
. Setpositivebutton ("OK", null). Create ();
Gets the Window object of the dialog box
Window Mwindow = Mdialog.getwindow ();
Windowmanager.layoutparams LP = Mwindow.getattributes ();
The scope of transparency is: 0.0f-1.0f;0.0f is completely transparent and 1.0f is completely opaque (this is the default for the system).
Lp.alpha = 0.35f;
The settings dialog is displayed at the bottom of the screen and, of course, up or down, anywhere
Mwindow.setgravity (Gravity.left);
Mwindow.setgravity (Gravity.bottom);
/*
*
* Here is the set offset, where x, Y is not relative to the absolute coordinates of the screen, but rather relative to the dialog box in the center position (the default dialog box is generally displayed in the center of the screen)
lp.x = -20;//Set Horizontal offset
LP.Y = -90;//Set vertical offset
*/
Set Properties for Window
Mwindow.setattributes (LP);
Mdialog.show ();
}
dialog display in different locations of activity