Skip to content

Instantly share code, notes, and snippets.

@hwd6190128
Last active May 21, 2019 09:35
Show Gist options
  • Save hwd6190128/8c97c271479b9c801f00ca4193fd6d27 to your computer and use it in GitHub Desktop.
Save hwd6190128/8c97c271479b9c801f00ca4193fd6d27 to your computer and use it in GitHub Desktop.
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
dialog?.window?.setFlags(
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
)
activity?.run {
dialog?.window?.decorView?.systemUiVisibility = this.window.decorView.systemUiVisibility
}
dialog?.setOnShowListener {
try {
//Clear the not focusable flag from the window
dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
//Update the WindowManager with the new attributes (no nicer way I know of to do this)..
val wm = activity?.getSystemService(Context.WINDOW_SERVICE) as WindowManager
wm.updateViewLayout(dialog?.window?.decorView, dialog?.window?.attributes)
} catch (e: Exception) {
e.printStackTrace()
}
}
return super.onCreateView(inflater, container, savedInstanceState)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment