How to make a custom dialog transparent?

10,504

Solution 1

You can also use following line in constructor

getWindow().setBackgroundDrawable(new ColorDrawable(0));

Solution 2

To make the background of the Dialog transparent you just need to set the theme of dialog to be android.R.style.Theme_Translucent_NoTitleBar. eg:-

new AlertDialog.Builder(context, android.R.style.Theme_Translucent_NoTitleBar).show();
Share:
10,504
Hardik Gajjar
Author by

Hardik Gajjar

Updated on June 18, 2022

Comments

  • Hardik Gajjar
    Hardik Gajjar almost 2 years

    I need to make my custom dialog transparent.

    How can I do that?

  • Codeversed
    Codeversed almost 12 years
    to setBackgroundDrawable you would need a ColorDrawable and in this case @Tarun Nagpal has the correct way of doing this.