如何动态修改Android对话框的位置

How to dynamically modify the position of Android Dialog

If: This is a pop-up dialog by default in the bottom of the window When I click the input box, how to make the top of the dialog dynamic rise of the keyboard, not just the keyboard is blocked?

AlertDialog.Builder builder = new AlertDialog.Builder(this);

 AlertDialog dialog = builder.create();
 dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
 WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();

wmlp.gravity = Gravity.TOP | Gravity.LEFT; wmlp.x = 100; //x位置enter code here wmlp.y = 100; //y 位置

dialog.show();

您需要设置对话框的x,y位置:

AlertDialog.Builder builder = new AlertDialog.Builder (this);

//set your builder
AlertDialog dialog = builder.Create ();
dialog.Window.Attributes.X = 34;
dialog.Window.Attributes.Y = 17;