Android – How to remove black border from AlertDialog builder

androidandroid-alertdialog

I have created a custom dialog using AlertDialog.builder. In this dialog, I am not displaying the title. All works fine but there is a black border in the dialog. So can anyone tell me how can I remove this black border? The code and screenshot are below.

Code in 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();
    }
});

ScrrenShot

enter image description here

Best Answer

Without creating a custom background drawable and adding a special style just add

one line to your code:

dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

More About Dialogs :

Dilaogs

Related Topic