0
是否有可能使BottomSheetDialogFragment不是模態?這意味着不會調暗底層內容,也不會阻止與它的交互。BottomSheetDialogFragment非模態
也許只能通過經典的片段?
是否有可能使BottomSheetDialogFragment不是模態?這意味着不會調暗底層內容,也不會阻止與它的交互。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);
}
}
}
擴展BottomSheetDialogFragment
類從this文章。
嗨,謝謝,但這似乎沒有做我所需要的 – luky
但它是有幫助的,因爲它顯示瞭如何以編程方式獲取行爲 – luky
@luky爲什麼你不編輯答案或發佈一個完全解決你的問題題? – rpattabi