【android】把AlertDialog后面黑背景设置全透明,昏暗度为0

  核心代码:

       dialog.getWindow().setDimAmount(0);//设置昏暗度为0


public void showDialog(){
        AlertDialog dialog = new AlertDialog.Builder(getContext()).create();
        dialog.getWindow().setDimAmount(0);//设置昏暗度为0
        dialog.setCanceledOnTouchOutside(true);
        dialog.show();
        //设置自定义布局,必须要在show之后
        dialog.getWindow().setContentView(R.layout.layout_menu_black);
    }

效果图:


猜你喜欢

转载自blog.csdn.net/u013372185/article/details/52538458