728x90

 

1. show와 동시에 fullscreen

    override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val bottomSheetDialog = BottomSheetDialog(
            requireContext(),
            theme
        ) bottomSheetDialog . setOnShowListener { dialog ->
            val bottomSheet =
                (dialog as BottomSheetDialog).findViewById<FrameLayout>(com.google.android.material.R.id.design_bottom_sheet) BottomSheetBehavior . from (bottomSheet).state =
                    BottomSheetBehavior.STATE_EXPANDED BottomSheetBehavior . from (bottomSheet).skipCollapsed =
                    true BottomSheetBehavior . from (bottomSheet).isHideable = true
        } return bottomSheetDialog
    }

 

2. 터치와 드래그를 막아 뒤로 가기를 누르거나 따로 dismiss를 해주어야만 fragment가 종료되도록 구현 가능

   override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        return BottomSheetDialog(
            requireContext(),
            theme
        ).apply {
            setOnShowListener {
                window?.findViewById<View>(R.id.touch_outside)
                    ?.setOnClickListener(null)(window?.findViewById<View>(R.id.design_bottom_sheet)?.layoutParams as CoordinatorLayout.LayoutParams).behavior =
                    null
            }
        }
    }


Reference

myung6024.tistory.com/171
myung6024.tistory.com/172

728x90

+ Recent posts