美文网首页
Android对话框宽度无法调整过宽的问题

Android对话框宽度无法调整过宽的问题

作者: plusend | 来源:发表于2016-09-20 15:06 被阅读192次

设置 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);

相关文章

网友评论

      本文标题:Android对话框宽度无法调整过宽的问题

      本文链接:https://www.haomeiwen.com/subject/xbroettx.html