How to set Transparent Background as a Custom Dialog Box in android

前端 未结 8 1057
梦谈多话
梦谈多话 2021-02-02 17:52

I need to make my custom dialog box as a transparent.

Sample Code :

Dialog dialog;
@Override
protected Dialog onCreateDialog(int id) 
{ 
    switch(id) 
         


        
8条回答
  •  既然无缘
    2021-02-02 18:18

    If you are on API >= 11, you can try to set a theme to your Dialog like that :

    new AlertDialog.Builder(mContext , android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
    

    Or you can try to set the background transparent :

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

提交回复
热议问题