gpt4 book ai didi

java - 警报对话框 : the background color is not transparent on some devices

转载 作者:太空宇宙 更新时间:2023-11-04 12:34:52 26 4
gpt4 key购买 nike

我正在 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,您的问题将会得到解决。

关于java - 警报对话框 : the background color is not transparent on some devices,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37438181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com