Skip to content

Instantly share code, notes, and snippets.

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 yasukotelin/31ed251b514e011c6aaaada1b92ae780 to your computer and use it in GitHub Desktop.
Save yasukotelin/31ed251b514e011c6aaaada1b92ae780 to your computer and use it in GitHub Desktop.
BottomSheetDialogFragmentを全画面表示するExtension。onViewCreatedでcallする。
/**
* BottomSheetDialogを全画面表示する
*/
fun BottomSheetDialogFragment.fullScreen() {
dialog?.setOnShowListener { dialog ->
val d = dialog as BottomSheetDialog
val bottomSheet =
d.findViewById<FrameLayout>(R.id.design_bottom_sheet) ?: return@setOnShowListener
bottomSheet.layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT
val screenHeight = Resources.getSystem().displayMetrics.heightPixels
BottomSheetBehavior.from(bottomSheet).peekHeight = screenHeight
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment