[英]AlertDialog : the background color is not transparent on some devices
我在Activity中显示一个对话框。
我使用此代码将背景颜色设置为透明
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
对话框背景显示透明,但当我在其他设备上测试我的应用程序时会出现问题。
它显示白色背景而不是透明。
我不知道在不同的设备中使用相同的代码会如何发生问题。
这是我的代码
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.update_client, null);
****** some code*******
dialogBuilder.setView(dialogView);
alertDialog = dialogBuilder.create();
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
// alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
alertDialog.setCanceledOnTouchOutside(false);
alertDialog.show();
}
尝试使用Dialog
而不是AlertDialog
,您的问题将得到解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.