Created
April 1, 2020 06:31
-
-
Save TedaLIEz/56d3009ec1167dc4db7534a532d95f99 to your computer and use it in GitHub Desktop.
Show popupwindow with dim background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun PopupWindow.dimBehind(dim: Float = 0.3f) { | |
val container: View = contentView.rootView | |
val context = contentView.context | |
val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager; | |
val p = container.layoutParams as WindowManager.LayoutParams; | |
p.flags = p.flags or WindowManager.LayoutParams.FLAG_DIM_BEHIND; // add a flag here instead of clear others | |
p.dimAmount = dim | |
wm.updateViewLayout(container, p); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment