Android 设置Dalog大小

注意:设置Dialog大小的代码,必须放在setContentView代码后面。否则设置无效。

  Dialog processDialog=new Dialog(this);
  TextView txt = new TextView(this);
  txt.setText("hello");
  processDialog.setContentView(txt);
        
  WindowManager.LayoutParams layoutParams=processDialog.getWindow().getAttributes();
  layoutParams.height=LayoutParams.FILL_PARENT;
  layoutParams.width=LayoutParams.FILL_PARENT;
  processDialog.getWindow().setAttributes(layoutParams);

  processDialog.getWindow().setBackgroundDrawableResource(R.drawable.sc_app_bg_pressed);
  
  processDialog.show();

评论

暂无评论