AlertDialog.Builder builder = new AlertDialog.Builder(this);
AlertDialog dialog = builder.create();
dialog.show();
Window window = dialog.getWindow();WindowManager.LayoutParams params = window.getAttributes();
params.width = 750; //设置对话框的宽度
params.height = 550; //设置对话框的高度
params.dimAmount = 0.9f; //调整对话框弹出后的背景亮度(0.0 — 1.0f:由亮到暗)
window.setAttributes(params);View contentView = View.inflate(this, R.layout.fitment_detail, null);
//如果要设置对话框里面控件的监听事件,需要通过contentView.findViewById()找到控件后设置
window.setContentView(contentView);
效果图: