我在設置高度和警告對話框的寬度的問題,下面是我的,我已經寫在OnCreateDialog碼()方法:如何設置默認警報對話框的高度和寬度
AlertDialog dialog = new AlertDialog.Builder(context ,AlertDialog.THEME_HOLO_LIGHT)
.setTitle("Title")
.setAdapter(adapter, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch(which){
case 0:
//some Code
break;
case 1:
//some Code
break;
}
}
})
.create();
WindowManager.LayoutParams WMLP = dialog.getWindow().getAttributes();
WMLP.x = 80; //x position
WMLP.y = -100; //y position
WMLP.height = 100;
WMLP.width = 100;
dialog.getWindow().setAttributes(WMLP);
//OR
dialog.getWindow().setLayout(100, 100);
請告訴我這裏的守則有什麼問題。由於
可能重複 [http://stackoverflow.com/questions/4406804/how-to-control-the-width-and-height-of-default-alert-dialog-in-android][1 ] [1]:http://stackoverflow.com/questions/4406804/how-to-control-the-width-and-height-of-default-alert-dialog-in-android – Simon 2012-02-09 07:21:20