I have a class that extends : DialogFragment()
so I need to make it close if I touch outside. I have tried this solutions but its not working. Please help me find the way to close it by clicking outside the window
How to dismiss a DialogFragment when pressing outside the dialog?
My code
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
_binding = MyFragmentDialogBinding.inflate(
LayoutInflater.from(requireContext()),
activity?.window?.decorView as ViewGroup,
false
)
val glassDialog = GlassDialog(requireActivity(), binding.root)
glassDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
glassDialog.setCanceledOnTouchOutside(true)
glassDialog.setCancelable(true)
return glassDialog
}