我创建了一个 BottomSheetDialogFragment
我想调整它的最大展开高度。我怎样才能做到这一点?我可以检索 BottomSheetBehaviour
但我能找到的只是窥视高度的设置器,而扩展高度则没有。
public class DialogMediaDetails extends BottomSheetDialogFragment
{
@Override
public void setupDialog(Dialog dialog, int style)
{
super.setupDialog(dialog, style);
View view = View.inflate(getContext(), R.layout.dialog_media_details, null);
dialog.setContentView(view);
...
View bottomSheet = dialog.findViewById(R.id.design_bottom_sheet);
BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
behavior.setPeekHeight(...);
// how to set maximum expanded height???? Or a minimum top offset?
}
}
编辑
为什么我需要那个?因为我在全屏活动中显示了一个 BottomSheet
对话框,如果 BottomSheet
在顶部留下一个空格,它看起来很糟糕……
原文由 prom85 发布,翻译遵循 CC BY-SA 4.0 许可协议
获取工作表行为的参考,
关闭
fitToContents
并将expandedOffset
设置为所需的像素。