Android Borderless Dialog

后端 未结 8 1820
囚心锁ツ
囚心锁ツ 2020-12-02 14:29

I have created an AlertDialog using AlertDialog.Builder, but the Dialog border takes up too much space on the screen. How do I remove the border? I have tried using another

8条回答
  •  萌比男神i
    2020-12-02 15:22

    In your resources file create a xml file named for e.g. null_image.xml, with the following content:

    
    
    
    
    
    
    
     
    

    In your java code, fetch the dialog window and set the xml file as the drawable resource, like this: Depending on your context:

    Dialog dialog = new Dialog(getContext());
    Window window = dialog.getWindow();
    window.setBackgroundDrawableResource(R.drawable.null_image);
    

    That's it, enjoy.

提交回复
热议问题