Can't create rounded corners Dialog (Android-Eclipse)

后端 未结 1 817
误落风尘
误落风尘 2021-01-03 16:46

I\'m trying to make a custom dialog shape for my app\'s dialogs. I\'ve been searching for this topic for hours, but the solutions I find don\'t work for me, that\'s why I as

相关标签:
1条回答
  • 2021-01-03 17:03

    The key thing to remove default android frame is:

    MyDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    

    Here is the full example:

    Dialog MyDialog= new Dialog(MyActivity.this);
    MyDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    MyDialog.setContentView(R.layout.my_custom_dialog);
    MyDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    MyDialog.show();
    
    0 讨论(0)
提交回复
热议问题