gpt4 book ai didi

android - 如何更改 bottomsheet 对话框 fragment 的默认高度?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:22:29 24 4
gpt4 key购买 nike

在使用 bottomsheet 对话框 fragment 时,它会为 bottomsheet 对话框设置默认高度。在我的应用程序中,我想为 bottomsheet 对话框设置 80% 的高度。如何将底部对话框的高度设置为 80%?

最佳答案

试试下面的代码。

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();

关于android - 如何更改 bottomsheet 对话框 fragment 的默认高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46551405/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com