首页 > 代码库 > 更改AlertDialog窗口大小的方法

更改AlertDialog窗口大小的方法

AlertDialog dialog = new AlertDialog.Builder(this).create();
dialog.show();
WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = 200;
params.height = 200 ;
dialog.getWindow().setAttributes(params);

这里需要注意的地方就是,一定要等dialog.show调用了过后,进行设置才会有效果。