android custom dialog background

前端 未结 5 828
故里飘歌
故里飘歌 2021-01-05 05:45

I need to show a custom dialog in my Android application. Standard AlertDialog design is unacceptable. Android docs say:

Tip: If you want

5条回答
  •  情书的邮戳
    2021-01-05 06:09

    Try...

    You can avoid the gray background like this, Here I did get transparent background.

        ........
        Dialog dialog = new Dialog(MainActivity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        Window window = dialog.getWindow();
        window.setBackgroundDrawableResource(android.R.color.transparent);
        dialog.setContentView(R.layout.popup_layout);
        Button dialogBtn= (Button) dialog.findViewById(R.id.btn);
    
        dialogBtn.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
                //task
            }
        });
        dialog.show();
        .......
    

提交回复
热议问题