问题
While using bottomsheet dialog fragment it set default height for bottomsheet dialog. In my application I want to set 80% height for bottomsheet dialog. How can I set 80% height to bottomsheet dialog?
回答1:
Try this following code.
super.setupDialog(dialog, style);
View contentView = View.inflate(getContext(), R.layout.activity_device_nfclocation, null);
DisplayMetrics displayMetrics = getActivity().getResources().getDisplayMetrics();
int width = displayMetrics.widthPixels;
int height = displayMetrics.heightPixels;
int maxHeight = (int) (height*0.88);
BottomSheetBehavior mBehavior = BottomSheetBehavior.from((View) contentView.getParent());
mBehavior.setPeekHeight(maxHeight);
dialog.show();
来源:https://stackoverflow.com/questions/46551405/how-to-change-the-default-height-of-bottomsheet-dialog-fragment