Bottom Sheet Dialog Fragment Expand Full Height
1 min readDec 6, 2018
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.”
the solution for this issue is.
@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);
}
});
}