我最近使用了android.support.design.widget.BottomSheetDialogFragment.我想做一些类似于谷歌联系人应用程序的东西,它的BottomSheet可以覆盖工具栏和状态栏.但是,当我使用BottomSheetDialogFragment实现它时,结果如下:

如您所见,活动的工具栏仍然可见.这是我的代码BottomSheetDialogFragment:
public class KeyDetailFragment 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(getActivity(), R.layout.sheet_key, null);
dialog.setContentView(contentView);
View parent = (View) contentView.getParent();
parent.setFitsSystemWindows(true);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(parent);
contentView.measure(0, 0);
bottomSheetBehavior.setPeekHeight(contentView.getMeasuredHeight());
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) parent.getLayoutParams(); …Run Code Online (Sandbox Code Playgroud)