我用NestedScrollView实现了底部表现行为.并且想知道在外面触摸时是否可以隐藏底部视图.
我已经实现了一个BottomSheet对话框,我希望当用户在偷看时(未完全展开状态)触摸底部外面时防止底片消失.
我已经设置dialog.setCanceledOnTouchOutside(false);了代码,但它似乎没有任何影响.
这是我的BottomSheetDialogFragment类:
public class ShoppingCartBottomSheetFragment extends BottomSheetDialogFragment  {
    private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback = new BottomSheetBehavior.BottomSheetCallback() {
        @Override
        public void onStateChanged(@NonNull View bottomSheet, int newState) {
            if (newState == BottomSheetBehavior.STATE_HIDDEN) {
                dismiss();
            }
        }
        @Override
        public void onSlide(@NonNull View bottomSheet, float slideOffset) {
        }
    };
    @Override
    public void setupDialog(Dialog dialog, int style) {
        super.setupDialog(dialog, style);
        View contentView = View.inflate(getContext(), R.layout.fragment_shopping_cart_bottom_sheet, null);
        dialog.setCanceledOnTouchOutside(false);
        dialog.setContentView(contentView);
        CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
        CoordinatorLayout.Behavior behavior = params.getBehavior();
        if( behavior != null && behavior …