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

前端 未结 8 1059
梦谈多话
梦谈多话 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条回答
  •  -上瘾入骨i
    2021-02-02 18:24

    Use dialog.getWindow().setBackgroundDrawable(null) to remove the default background.

    Here is the doc for reference:

    /*** Set the background to a given Drawable, or remove the background. If the
       * background has padding, this View's padding is set to the background's
       * padding. However, when a background is removed, this View's padding isn't
       * touched. If setting the padding is desired, please use
       * {@link #setPadding(int, int, int, int)}.
       *
       * @param d The Drawable to use as the background, or null to remove the
       *        background
       */
    

提交回复
热议问题