public void show(Context context){
CommonDialog dialog = new CommonDialog(context);
Window window = dialog.getWindow();
if (window != null) {
View view = LayoutInflater.from(context).inflate(R.layout.dialog, null);
dialog.setContentView(view);
WindowManager.LayoutParams wl = window.getAttributes(); //获得窗口的属性对象
wl.x = 0;
wl.y = 180;
wl.width = 1000;
wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;
wl.gravity = Gravity.START | Gravity.BOTTOM;
dialog.onWindowAttributesChanged(wl); //设置对话框显示的窗口属性为wl
dialog.setCanceledOnTouchOutside(false);
view.findViewById(R.id.cancel).setOnClickListener(v -> {
dialog.cancel();
});
}
dialog.show();
}