Skip to content

Instantly share code, notes, and snippets.

@yogeshpaliyal
Created November 15, 2021 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yogeshpaliyal/982d567b87b9ec64581cd63624ac29ca to your computer and use it in GitHub Desktop.
Save yogeshpaliyal/982d567b87b9ec64581cd63624ac29ca to your computer and use it in GitHub Desktop.
Show full screen bottom sheet
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState)
dialog.setOnShowListener { dialogInterface ->
dialog.window?.findViewById<View>(R.id.design_bottom_sheet)?.let { bottomSheetView ->
bottomSheetView.background = null
/* bottomSheetView.let {
BottomSheetBehavior.from(it).isFitToContents = true
BottomSheetBehavior.from(it).state = BottomSheetBehavior.STATE_EXPANDED
}*/
val bottomSheetDialog = dialogInterface as BottomSheetDialog
setupFullHeight(bottomSheetDialog)
}
}
return dialog
}
private fun setupFullHeight(bottomSheetDialog: BottomSheetDialog) {
val bottomSheet: FrameLayout? = bottomSheetDialog.findViewById<View>(R.id.design_bottom_sheet) as FrameLayout?
val behavior: BottomSheetBehavior<*> = BottomSheetBehavior.from(bottomSheet!!)
val layoutParams: ViewGroup.LayoutParams = bottomSheet.layoutParams
val windowHeight = Resources.getSystem().displayMetrics.heightPixels
layoutParams.height = windowHeight
behavior.peekHeight = windowHeight
bottomSheet.layoutParams = layoutParams
behavior.state = BottomSheetBehavior.STATE_EXPANDED
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment