Dynamically change height of BottomSheetBehavior

后端 未结 9 1113
既然无缘
既然无缘 2020-12-13 03:42

I\'m using the BottomSheetBehavior from Google recently released AppCompat v23.2. The height of my bottom sheet depends on the content displayed inside of the b

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 04:32

    For bottom sheet dialog fragment, read this: Bottom Sheet Dialog Fragment Expand Full Height

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
       super.onActivityCreated(savedInstanceState);
    
       BottomSheetDialog dialog = (BottomSheetDialog) getDialog();
    
       FrameLayout bottomSheet = dialog.findViewById(com.google.android.material.R.id.design_bottom_sheet);
       BottomSheetBehavior behavior = BottomSheetBehavior.from(bottomSheet);
       behavior.setState(BottomSheetBehavior.STATE_EXPANDED);
       behavior.setPeekHeight(0);
    }
    

提交回复
热议问题