Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. val popup = PopupWindow(...)
  2.  
  3. val container = popup.contentView.takeIf { it.layoutParams is WindowManager.LayoutParams }
  4. ?: (popup.contentView.parent as? View)?.takeIf { it.layoutParams is WindowManager.LayoutParams }
  5. ?: (popup.contentView.parent.parent as? View)?.takeIf { it.layoutParams is WindowManager.LayoutParams }
  6. ?: throw IllegalStateException("NO WindowManager.LayoutParams!")
  7.  
  8. val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
  9. val lp = container.layoutParams as WindowManager.LayoutParams
  10. lp.flags = lp.flags or WindowManager.LayoutParams.FLAG_DIM_BEHIND
  11. lp.dimAmount = 0.3f
  12. wm.updateViewLayout(container, lp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement