为什么警报生成器对话框的拐角处有额外的黑色?
Why the alertbuilder dialog is having extra black color around the corners?
我正在尝试动态构建如下所示的警报对话框。一切正常。
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);
除了我在角落周围有额外的黑色,如下所示
请让我知道哪里做错了。
谢谢,
沙拉斯
添加此代码
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
我正在尝试动态构建如下所示的警报对话框。一切正常。
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);
除了我在角落周围有额外的黑色,如下所示
请让我知道哪里做错了。
谢谢, 沙拉斯
添加此代码
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));