개발/안드로이드 개발
BottomSheetDialogFragment 드래그 되지 않게 막는 방법
룬아님
2020. 1. 16. 18:00
사실 바텀시트에서 드래그를 막아야 하는 경우는 드믈지만 터치와 드래그를 막아 뒤로 가기를 누르거나 따로 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
}
}
}
https://stackoverflow.com/a/48362662
반응형