최대높이로 기본부터 설정되게 하는법!!

https://velog.io/@nimok97/안드로이드-BottomSheetDialogFragment-원하는-높이-비율-설정하기

https://material.io/archive/guidelines/components/bottom-sheets.html#bottom-sheets-specs

BottomSheetDialogFragment 버전

class ShortsBottomSheetFragment : BottomSheetDialogFragment() {

    private var _binding: FragmentShortsBottomSheetBinding? = null
    private val binding get() = _binding!!

    private val viewModel: ShortsBottomSheetViewModel by activityViewModels()
    private val parentViewModel: ShortsViewModel by activityViewModels()

    fun LifecycleOwner.repeatOnStarted(block: suspend CoroutineScope.() -> Unit) {
        viewLifecycleOwner.lifecycleScope.launch {
            lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED, block)
        }
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = DataBindingUtil.inflate(
            inflater,
            R.layout.fragment_shorts_bottom_sheet,
            container,
            false
        )
        return binding.root
    }

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val dialog = super.onCreateDialog(savedInstanceState)
        dialog.setOnShowListener { dialogInterface ->
            val bottomSheetDialog = dialogInterface as BottomSheetDialog
            setupRatio(bottomSheetDialog)
        }
        return dialog
    }

    private fun setupRatio(bottomSheetDialog: BottomSheetDialog){
        val bottomSheet = bottomSheetDialog.findViewById<View>(com.google.android.material.R.id.design_bottom_sheet) as View
        val behavior = BottomSheetBehavior.from(bottomSheet)
        behavior.state = BottomSheetBehavior.STATE_EXPANDED
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        initEventObserve()
    }

    private fun initEventObserve() {
        repeatOnStarted {
            viewModel.applyFilter.collect {
                parentViewModel.applyFilter(it)
                dismiss()
            }
        }
    }
}

BottomSheetDialog 버전