您的位置:首页 > 其它

更改AlertDialog窗口大小的方法

2015-05-21 13:13 176 查看
<span style="background-color: rgb(255, 255, 255);">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调用了过后,进行设置才会有效果。</span>


void onPrepareDialog(int id, Dialog dialog)中修改Dialog以定制

//布局

dialog.setContentView(R.layout.dialog_warn_net);

//大小

dialog.getWindow().setLayout(dlgWidth, dlgHeight);

//位置

dialog.getWindow().getAttributes().x = mDialogLayoutParamsX;

dialog.getWindow().getAttributes().y = mDialogLayoutParamsY;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: