我使用 AlertDialog.builder
创建了一个自定义对话框。在这个对话框中,我没有显示标题。一切正常,但对话框中有黑色边框。那么谁能告诉我如何删除这个黑色边框?代码和截图如下。
Java 代码:
AlertDialog.Builder start_dialog = new AlertDialog.Builder(this);
Context mContext = getApplicationContext();
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.custom_dialog2,
(ViewGroup) findViewById(R.id.layout_root));
layout.setBackgroundResource(R.drawable.img_layover_welcome_bg);
Button btnPositiveError = (Button)layout.findViewById(R.id.btn_error_positive);
btnPositiveError.setTypeface(m_facedesc);
start_dialog.setView(layout);
final AlertDialog alert = start_dialog.create();
alert.show();
btnPositiveError.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View v)
{
alert.dismiss();
}
});
屏幕截图
最佳答案
Without creating a custom background drawable and adding a special style just add
一行代码:
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
关于对话框的更多信息:
关于android - 如何从 AlertDialog 构建器中删除黑色边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8193412/