我正在尝试动态构建如下警告对话框。一切都很好。
final Builder builder = new AlertDialog.Builder(context);
builder.setView(view);
builder.setCancelable(true);
builder.setOnCancelListener(new SortOnCancelListener(viewable, this));
dialog = builder.create();
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(dialog.getWindow().getAttributes());
DisplayMetrics displaymetrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
lp.width = (int) ((int)displaymetrics.widthPixels * 0.6);
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
dialog.show();
dialog.getWindow().setAttributes(lp);
请让我知道我在哪里做错了。
谢谢, 沙拉斯
答案 0 :(得分:1)
添加此代码
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));