How to make custom dialog with rounded corners in android

前端 未结 16 866
半阙折子戏
半阙折子戏 2020-11-28 02:15

What I am trying to do: I am trying to make a custom dialog in android With rounded corners.

What is happening: I am able to make c

16条回答
  •  北海茫月
    2020-11-28 02:20

    Create a xml in drawable , say dialog_bg.xml

    
    
        
        
        
    
    

    set it as the background in your layout xml

    android:background="@drawable/dialog_bg"
    

    Set the background of the dialog's root view to transparent, because Android puts your dialog layout within a root view that hides the corners in your custom layout.

    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    

提交回复
热议问题