mac
2024-05-16 7fdae87bc3de46b5b012f8987c6902cd8b054323
app/src/main/java/com/hdl/photovoltaic/widget/TypeTitleListDialog.java
@@ -67,38 +67,39 @@
    @Override
    protected void onStart() {
        super.onStart();
        // 获取窗口对象
        Window dialogWindow = this.getWindow();
        if (dialogWindow != null) {
            // 获取对话框当前的参数值
            WindowManager.LayoutParams p = dialogWindow.getAttributes();
            p.width = LinearLayout.LayoutParams.MATCH_PARENT;
            p.height = LinearLayout.LayoutParams.WRAP_CONTENT;
            p.dimAmount = 0.6f;
            dialogWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            p.gravity = Gravity.BOTTOM;
            p.y = DensityUtils.dip2px(mContext, 70);
//            //这里设置的宽高优先级高于XML中的布局设置
//            if (this.enumBoxType == BoxType.PhotoAlbumBox) {
//                p.gravity = Gravity.BOTTOM;
//            } else if (this.enumBoxType == BoxType.FlashingBox) {
//                p.dimAmount = 0f;
//            }
            // 设置到属性配置中
            dialogWindow.setAttributes(p);
        }
//        // 获取窗口对象
//        Window dialogWindow = this.getWindow();
//        if (dialogWindow != null) {
//            // 获取对话框当前的参数值
//            WindowManager.LayoutParams p = dialogWindow.getAttributes();
//            p.width = LinearLayout.LayoutParams.MATCH_PARENT;
//            p.height = LinearLayout.LayoutParams.WRAP_CONTENT;
////            p.dimAmount = 0.6f;
//            dialogWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//            p.gravity = Gravity.BOTTOM;
//            p.y = DensityUtils.dip2px(mContext, 352);
////            //这里设置的宽高优先级高于XML中的布局设置
////            if (this.enumBoxType == BoxType.PhotoAlbumBox) {
////                p.gravity = Gravity.BOTTOM;
////            } else if (this.enumBoxType == BoxType.FlashingBox) {
////                p.dimAmount = 0f;
////            }
//            // 设置到属性配置中
//            dialogWindow.setAttributes(p);
//        }
//        setDialogTouchOutsideCloseable(this);
    }
    @SuppressLint("ClickableViewAccessibility")
    public void setDialogTouchOutsideCloseable(Dialog dialog) {
        viewBinding.getRoot().setOnClickListener(new View.OnClickListener() {
        viewBinding.typeParentCl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int top = viewBinding.typeParentCl.getTop();
                int left = viewBinding.typeParentCl.getLeft();
                int bottom = viewBinding.typeParentCl.getBottom();
                int right = viewBinding.typeParentCl.getRight();
                int top = viewBinding.dialogParentCl.getTop();
                int left = viewBinding.dialogParentCl.getLeft();
                int bottom = viewBinding.dialogParentCl.getBottom();
                int right = viewBinding.dialogParentCl.getRight();
                int y = (int) v.getY();
                int x = (int) v.getX();
                if (top < y && y < bottom) {