ghostwan
3/14/2019 - 4:50 PM

Floating view android

Floating view android

private fun showBackButton() {
    val windowManager = getSystemService(Context.WINDOW_SERVICE) as WindowManager
    val floatingBubbleView = LayoutInflater.from(this).inflate(R.layout.box, null)
    val params = WindowManager.LayoutParams(
        WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.WRAP_CONTENT,
        WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG,
        WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
        PixelFormat.TRANSLUCENT
    )
    params.gravity = Gravity.CENTER
    params.x = 50
    params.y = 100
    windowManager.addView(floatingBubbleView, params)
}