override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (dialog is BottomSheetDialog) { val behaviour = (dialog as BottomSheetDialog).behavior behaviour.state = BottomSheetBehavior.STATE_EXPANDED } }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (dialog is BottomSheetDialog) { val behaviour = (dialog as BottomSheetDialog).behavior behaviour.isDraggable=false } }
override fun onSlide(bottomSheet: View, slideOffset: Float) {
} }) } }
设置默认进入展开状态下拉不进入折叠状态
1 2 3 4 5 6 7 8 9 10
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (dialog is BottomSheetDialog) { val behaviour = (dialog as BottomSheetDialog).behavior behaviour.state = BottomSheetBehavior.STATE_EXPANDED //表示在隐藏时,跳过折叠状态,直接进入隐藏状态。 behaviour.skipCollapsed = true; } }
设置弹窗固定高度
方式一.
1 2 3 4 5 6 7 8 9 10 11 12
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) if (dialog is BottomSheetDialog) { val behaviour = (dialog as BottomSheetDialog).behavior behaviour.state = BottomSheetBehavior.STATE_EXPANDED