Skip to content

Instantly share code, notes, and snippets.

@ch8n
Created December 24, 2019 07:42
Show Gist options
  • Save ch8n/65dba9188996b9b63ab749fd9d21f502 to your computer and use it in GitHub Desktop.
Save ch8n/65dba9188996b9b63ab749fd9d21f502 to your computer and use it in GitHub Desktop.
BottomSheet Fragment access state
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val bottomSheet: BottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
bottomSheet.setOnShowListener { dialog ->
val bottomSheetDialog: BottomSheetDialog? = dialog as? BottomSheetDialog
val bottomSheetBehaviour = bottomSheetDialog?.findViewById(com.google.android.material.R.id.design_bottom_sheet) as? FrameLayout
BottomSheetBehavior.from(bottomSheetBehaviour).setState(BottomSheetBehavior.STATE_EXPANDED)
}
return bottomSheet
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment