【发布时间】:2025-12-01 01:05:01
【问题描述】:
我创建了一个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 在顶部留下一个空格,它看起来很糟糕......
【问题讨论】:
-
我很想知道如何为`modal bottom sheet`设置
max height。我需要我的模态底部工作表只到半屏,即使在拖动后也永远不会到顶部......有任何线索吗? -
@abat 希望对您有所帮助:*.com/a/53791225/1318946
-
@eRaisedToX 你也可以试试:*.com/a/53791225/1318946
标签: android android-support-library androiddesignsupport bottom-sheet