注意:设置Dialog大小的代码,必须放在setContentView代码后面。否则设置无效。
1 Dialog processDialog=new Dialog(this); 2 TextView txt = new TextView(this); 3 txt.setText("hello"); 4 processDialog.setContentView(txt); 5 6 WindowManager.LayoutParams layoutParams=processDialog.getWindow().getAttributes(); 7 layoutParams.height=LayoutParams.FILL_PARENT; 8 layoutParams.width=LayoutParams.FILL_PARENT; 9 processDialog.getWindow().setAttributes(layoutParams); 10 11 processDialog.getWindow().setBackgroundDrawableResource(R.drawable.sc_app_bg_pressed); 12 13 processDialog.show();