el-dialog 全透明
时间: 2023-10-04 14:12:56 浏览: 79
要将el-dialog设置为全透明,可以参考以下方法。首先,使用setContentView方法显示自定义的dialog布局之前,可以在onCreate方法中加入一行代码: getWindow().setBackgroundDrawableResource(android.R.color.transparent)。这行代码将对话框的布局主背景设置为透明。例如:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 设置布局背景为透明
getWindow().setBackgroundDrawableResource(android.R.color.transparent);
setContentView(R.layout.your_dialog_layout);
// ...
}
另外一种方法是使用AlertDialog.Builder来创建对话框。在设置完对话框的布局后,可以使用mDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent)将对话框的背景设置为透明。例如:
AlertDialog.Builder builder = new AlertDialog.Builder(context);
View view = View.inflate(context, R.layout.your_dialog_layout, null);
builder.setView(view);
AlertDialog mDialog = builder.create();
mDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
mDialog.show()。
这样,el-dialog就会被设置为全透明。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>