Open lwasyl opened 1 year ago
Hi @lwasyl, thanks for reporting this. Could you please attach a code sample or repo with any relevant code necessary to trigger this bug? It would be particularly helpful to see any XML layout files associated with the bottom sheet.
Ah disregard the above comment, I didn't notice that you attached a sample app.
I'm having the same problem. I've tried setting the design_bottom_sheet
layout to MATCH_PARENT
, but I get the same result as @lwasyl
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
Log.d(TAG, "onShow: onCreateDialog");
BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
dialog.setOnShowListener(dialog1 -> {
((BottomSheetDialog) dialog1).getBehavior().setFitToContents(false);
((BottomSheetDialog) dialog1).getBehavior().setState(BottomSheetBehavior.STATE_EXPANDED);
View bottomSheet = ((BottomSheetDialog) dialog1).findViewById(com.google.android.material.R.id.design_bottom_sheet);
if (bottomSheet != null) {
bottomSheet.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
}
});
// Do something with your dialog like setContentView() or whatever
return dialog;
}
any updates on this? have exactly same issue
Also have same issue.. any solutions? or updates?
Having the same issue.
Not sure whether this is a bug or intended to be like this. Here is what helped me: https://stackoverflow.com/a/76283458/6657837
My onViewCreated
method:
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
View parentLayout = ((BottomSheetDialog) getDialog()).findViewById(com.google.android.material.R.id.design_bottom_sheet);
ViewGroup.LayoutParams layoutParams = parentLayout.getLayoutParams();
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
parentLayout.setLayoutParams(layoutParams);
}
Description:
Simple bottom sheet that starts
expanded
and hasfitToContents=false
:will appear flying on top of the screen:
https://user-images.githubusercontent.com/3951580/195555156-25e88b5d-082d-4b7d-a1b8-08e9122d9f8f.mov
Expected behavior: Bottom sheet is full-screen, laid out with
match_parent
heightSource code: above
Minimal sample app repro: bottom-sheet.zip
Material Library version: 1.6.1