Bottom Sheet Dialog Fragment Expand Full Height

My Problem is that . “I am using BottomSheetDialogFragment in my activity, the dialog shows full height in portrait mode but doesn’t when I switch to landscape mode.”

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
BottomSheetDialog dialog = (BottomSheetDialog) getDialog();
// androidx should use: com.google.android.material.R.id.design_bottom_sheet FrameLayout bottomSheet = (FrameLayout)
dialog.findViewById(android.support.design.R.id.design_bottom_sheet);
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
behavior.setPeekHeight(0);
}
});
}

Oktein Company, Software Engineer, Python Enthusiast

Oktein Company, Software Engineer, Python Enthusiast