设置 Dialog 宽度的方法:
LayoutInflater inflater = LayoutInflater.from(mContext);
final View view = inflater.inflate(R.layout.ereb_call_log_dialog_delete, null);
final AlertDialog.Builder builder = new AlertDialog.Builder(mContext, R.style.Dialog);
builder.setView(view);
mAlertDialog = builder.create();
mAlertDialog.show();
mAlertDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
WindowManager.LayoutParams params = mAlertDialog.getWindow().getAttributes();
params.height = 531; // 177 * 3
params.width = 1011; // 377 * 3
mAlertDialog.getWindow().setAttributes(params);
mAlertDialog.show();
关键代码即:
mAlertDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);