Skip to content

Instantly share code, notes, and snippets.

@mhrpatel12
Created December 12, 2020 13:08
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 mhrpatel12/c019d8baada0c5ebe4c86347251d5ec3 to your computer and use it in GitHub Desktop.
Save mhrpatel12/c019d8baada0c5ebe4c86347251d5ec3 to your computer and use it in GitHub Desktop.
override fun onServiceConnected() {
super.onServiceConnected()
val wm = getSystemService(WINDOW_SERVICE) as WindowManager
val mLayout = FrameLayout(this)
val lp = WindowManager.LayoutParams()
lp.type = WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY
lp.format = PixelFormat.TRANSLUCENT
lp.flags = lp.flags or WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
lp.width = WindowManager.LayoutParams.WRAP_CONTENT
lp.height = WindowManager.LayoutParams.WRAP_CONTENT
lp.gravity = Gravity.TOP
val inflater = LayoutInflater.from(this)
inflater.inflate(R.layout.your_layout, mLayout)
wm.addView(mLayout, lp)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment