dialog想改變默認寬度,橫向全屏,要在show之後,修改Attributes,
其中
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
必不可少,不加此行,DecorView會有padding,橫向一直不能鋪滿屏幕
Window window = getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
lp.gravity = Gravity.CENTER;
lp.width = WindowManager.LayoutParams.MATCH_PARENT;//寬高可設置具體大小
getWindow().setAttributes(lp);
// 此行必不可少
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));