Set state of BottomSheetDialogFragment to expanded

前端 未结 14 868
有刺的猬
有刺的猬 2020-11-30 19:11

How do you set the state of a fragment extending BottomSheetDialogFragment to expanded using BottomSheetBehavior#setState(STATE_EXPANDED) using the

14条回答
  •  盖世英雄少女心
    2020-11-30 19:43

    My answer is more or less same as most of the above answers with a slight modification. Instead of using findViewById to first find the bottom sheet view, I have preferred not to hardcode any framework view resource ids since they might change in future.

    setOnShowListener(dialog -> {
                BottomSheetBehavior bottomSheetBehavior = ((BottomSheetDialog)dialog).getBehavior();
                bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
            });
    

提交回复
热议问题