private void setDialogSize(Dialog dg) { Window dialogWindow = dg.getWindow(); WindowManager.LayoutParams lp = dialogWindow.getAttributes(); dialogWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); dialogWindow.setGravity(Gravity.LEFT | Gravity.TOP); //显示的坐标 lp.x = 150; lp.y = 50; int width = getResources().getDimensionPixelOffset(R.dimen.d_width); int height = getResources().getDimensionPixelOffset(R.dimen.d_height); //dialog的大小 lp.width = width; lp.height = height; dialogWindow.setAttributes(lp); }