gpt4 book ai didi

android - BottomSheetDialogFragment 不是模态的

转载 作者:行者123 更新时间:2023-11-29 01:14:47 28 4
gpt4 key购买 nike

是否可以使 BottomSheetDialogFragment 不是模态的?这意味着底层内容不会变暗,也不会阻止与其交互。

也许只能通过经典 fragment ?

最佳答案

尝试用这种方式扩展BottomSheetDialogFragment

public class CustomBottomSheetDialogFragment extends BottomSheetDialogFragment {


@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}

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.dialog_modal, null);
dialog.setContentView(contentView);
CoordinatorLayout.LayoutParams layoutParams =
(CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = layoutParams.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
}
}

来自 this文章。

关于android - BottomSheetDialogFragment 不是模态的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40549032/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com