在dialog.show();后面加上
WindowManager windowManager = getWindowManager();Display display = windowManager.getDefaultDisplay();
WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
lp.width = (int)(display.getWidth()); //设置宽度
dialog.getWindow().setAttributes(lp);