dialog 默认的样式@android:style/Theme.Dialog 对应的style 有pading属性,所以
win.getDecorView().setPadding(0, 0, 0, 0); 就能够水平占满了。
项目使用代码如下:
ComplainDialog complain_dialog = new ComplainDialog(OrderDetialActivity.this,
R.style.customdialog_complain_style,
R.layout.complain_dialog);
Window win = complain_dialog.getWindow();
win.getDecorView().setPadding(0, 0, 0, 0);
WindowManager.LayoutParams lp = win.getAttributes();
lp.width = WindowManager.LayoutParams.FILL_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
win.setAttributes(lp);
complain_dialog.show();
complain_dialog
.setYourListener(new ComplainDialog.ComplainButtonListener() {
@Override
public void setComplainString(String complainString) {
if (!TextUtils.isEmpty(complainString)) {
setComplainInfo(complainString);
}
}
});
}
});