Skip to content

Instantly share code, notes, and snippets.

@TedaLIEz
Created April 1, 2020 06:31
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 TedaLIEz/56d3009ec1167dc4db7534a532d95f99 to your computer and use it in GitHub Desktop.
Save TedaLIEz/56d3009ec1167dc4db7534a532d95f99 to your computer and use it in GitHub Desktop.
Show popupwindow with dim background
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