Android Dialog - Rounded Corners and Transparency

后端 未结 11 552
日久生厌
日久生厌 2020-12-09 16:12

I\'m trying to make a custom android dialog with rounded corners. My current attempts have given me this result.

\"

11条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 16:33

    The below code solved the issue

    MyDialog mydialog = new MyDialog(this, "for testing",
                new myOnClickListener() {
    
                    @Override
                    public void onPositiveButtonClick() {
                        // TODO Auto-generated method stub
                        Toast.makeText(getApplicationContext(),
                                "I am positive button in the dialog",
                                Toast.LENGTH_LONG).show();
                    }
    
                    @Override
                    public void onNegativeButtonClick() {
                        // TODO Auto-generated method stub
                        Toast.makeText(getApplicationContext(),
                                "I am negative button in the dialog",
                                Toast.LENGTH_LONG).show();
                    }
                });
    
        // this will remove rectangle frame around the Dialog
        mydialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        mydialog.show();
    

    Thanks, Nagendra

提交回复
热议问题