gpt4 book ai didi

java - 如果我不设置 peekHeight,BottomSheetBehavior 不可拖动

转载 作者:行者123 更新时间:2023-11-30 00:18:06 34 4
gpt4 key购买 nike

在我的应用程序中,我有一个 Bottom Sheet 和一个使它折叠/展开的按钮。

如果未设置 peekHeight,则 Bottom Sheet 不可拖动且不会折叠,它始终可见。

代码如下:

        View bottomSheet = findViewById(R.id.bottom_sheet1);
mBottomSheetBehavior1 = BottomSheetBehavior.from(bottomSheet);

mBottomSheetBehavior1.setPeekHeight(0); //IF I OMIT THIS, IT DOES NOT WORK

mButton1 = (Button) findViewById(R.id.button_1);
mButton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mBottomSheetBehavior1.getState() != BottomSheetBehavior.STATE_EXPANDED) {
mBottomSheetBehavior1.setState(BottomSheetBehavior.STATE_EXPANDED);
mButton1.setText("Collapse 1");
}
else {
mBottomSheetBehavior1.setState(BottomSheetBehavior.STATE_COLLAPSED);
mButton1.setText("Expand 1");
}
}
});

怎么了?

最佳答案

默认情况下,BottomSheetBehavior 不是 hideable .

你必须明确地告诉你,你希望该行为是可隐藏的:


bottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
bottomSheetBehavior.setHideable(true);

关于java - 如果我不设置 peekHeight,BottomSheetBehavior 不可拖动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46809167/

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