Dialog with transparent background in Android

Programmer picture Programmer · May 29, 2012 · Viewed 215.5k times · Source

How do I remove the black background from a dialog box in Android. The pic shows the problem.

enter image description here

final Dialog dialog = new Dialog(Screen1.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.themechanger); 

Answer

Zacharias Manuel picture Zacharias Manuel · May 29, 2012

Add this code

 dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

Or this one instead:

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