BottomSheetDialogFragment 里面的 Fragment 问题

BottomSheetDialogFragment inside Fragment problem

在 Fragment 中显示 BottomSheetDialogFragment 并与特定按钮交互(如按照下图增加价格)后,Fragment 消失并按照第二张照片显示。

代码:

increase_price.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String coun_cost = shipment_price.getText().toString();

            if (coun_cost.isEmpty()) {
                counter_price = 0;
                counter_price = counter_price + 5;
                requestFocus(shipment_price);
                shipment_price.setText(String.valueOf(counter_price));
            } else {
                counter_price = Integer.valueOf(coun_cost);
                counter_price = counter_price + 5;
                requestFocus(shipment_price);
                shipment_price.setText(String.valueOf(counter_price));
            }
        }
    });

    decrement_price.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String coun_cost = shipment_price.getText().toString();

            if (!coun_cost.isEmpty()) {
                counter_price = Integer.valueOf(coun_cost);
                counter_price = counter_price - 5;
                if (counter_price >= 0) {
                    requestFocus(shipment_price);
                    shipment_price.setText(String.valueOf(counter_price));
                } else {
                    counter_price = 0;
                    requestFocus(shipment_price);
                    shipment_price.setText(String.valueOf(counter_price));
                }
            }
        }
    });

删除以下代码行后我的问题解决了。

    param = Objects.requireNonNull(getActivity()).getWindow().getAttributes();
    param.width = WindowManager.LayoutParams.MATCH_PARENT;
    param.height = WindowManager.LayoutParams.DIM_AMOUNT_CHANGED;