Dialog的大小除了可以引用自定义布局外, 还可以通过代码进行固定:
mDialog.show();
// Window window = mDialog.getWindow();
// window.getDecorView().setPadding(0, 0, 0, 0);
WindowManager.LayoutParams attrs = mDialog.getWindow().getAttributes();
//attrs.setTitle("Title");
attrs.width = WindowManager.LayoutParams.WRAP_CONTENT;// attrs.width =580;
attrs.height = WindowManager.LayoutParams.WRAP_CONTENT;// attrs.height = 600;
mDialog.getWindow().setAttributes(attrs);
还有一种, 可以通过手机设备的像素密度进行动态设置对话框的宽与高, 不至于同样像素的内容在分辨率不同的设备上出现不同的效果:
private<