Transparent AlertDialog has black background

The problem is that AlertDialog builder is actually not good for designing transparent dialog and will and always have this black background which is actually a Theme for it, instead use the Dialog to create a transparent theme instead.

sample:

Dialog alertDialog = new Dialog(this);
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
alertDialog.setContentView(R.layout.tabs);
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
alertDialog.show();

Using Dialog does not require any theme manipulation for transparent background so it is basically easy.

Leave a Comment