自定义对话框

示例代码:

public void showDialog() { AlertDialog.Builder builder = new Builder(this); View view = View.inflate(this, R.layout.dialog, null); builder.setView(view);//将自定义的View设置到对话框中
 builder.show() }

但是会发现对话框上面和下面都有一个小黑背景,这是因为对话框的默认背景是黑色的。那么怎么才让它去掉上面的黑背景呢?

public void showDialog() { AlertDialog.Builder builder = new Builder(this); View view = View.inflate(this, R.layout.dialog, null); AlertDialog dialog = builder.create(); dialog.setView(view,0,0,0,0);//设置填空的view据对话框的上下左右的距离
 dialog.show(); }

 

你可能感兴趣的:(自定义)