Android中Popupwindow无法自动获取焦点

580 阅读1分钟

不知道为什么, Popupwindow弹出之后, 无法自动将页面焦点转移到popupwindow中, 所以需要手动设置下:

        mWindow = PopupWindow(this).apply {
            this.contentView = binding.root
            this.width = LkDimens.dp2px(120)
            this.height = LkDimens.dp2px(132)
            this.isOutsideTouchable = true
            this.setBackgroundDrawable(ColorDrawable(0))
            this.isFocusable = true
        }