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

前端 未结 8 1076
梦谈多话
梦谈多话 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:24

    Use dialog instead of AlertDialog

    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.setContentView(R.layout.splash);
    dialog.show();
    

提交回复
热议问题