Custom Dialog without title and border

后端 未结 8 881
终归单人心
终归单人心 2021-02-01 20:19

Based on the code here, http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog . I am successfully able to create a custom dialog with background and buttons ins

8条回答
  •  迷失自我
    2021-02-01 21:09

    1. Make a class like this:

      public class CustomDialog extends Dialog {
          public AlertFinishiView(Context context) {
              super(context);
              requestWindowFeature(Window.FEATURE_NO_TITLE);
              setContentView(R.layout.dialog);
              getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
          }
      }
      
    2. make a xml in layut folder with this name dialog

      
      
      
         
      
            
    3. add the image above in your drawable folder with name bg_custom_dialog.9.png

    bg_custom_dialog

    1. call in your activity:

      CustomDialog customDialog = new CustomDialog(this);
      customDialog.show();
      

提交回复
热议问题