bottomSheetDialogFragment

bottomSheetDialogFragment

本文介绍了防止BottomSheetDialogFragment隐藏键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在当前活动/片段中打开了键盘,则当我显示BottomSheetDialogFragment时,键盘将被关闭,但我希望键盘停留在BottomSheetDialogFragment后面的背景中.当我显示BottomSheetDialogFragment时,有没有办法使键盘在bottomSheetDialogFragment后面保持打开状态并防止键盘被关闭?

If I have keyboard opened in current activity/fragment, when I present the BottomSheetDialogFragment, keyboard gets dismissed, but I want the keyboard to stay up in the background behind the BottomSheetDialogFragment. Is there a way to keep keyboard opened behind bottomSheetDialogFragment when I show the BottomSheetDialogFragment and prevent keyboard from being dismissed?

我正在这样显示BottomSheetDialogFragment:

I am showing the BottomSheetDialogFragment like this:

modalBottomSheet.show(
                (activity as AppCompatActivity).supportFragmentManager,
                ModalBottomSheet.TAG + System.currentTimeMillis().toString()
)

推荐答案

我知道了.在您的BottomSheetDialogFragment的子类中,在方法中:重写fun setupDialog(dialog:Dialog,style:Int),请执行以下操作:

I figured it out. In your BottomSheetDialogFragment's subclass, in the method: override fun setupDialog(dialog: Dialog, style: Int), do:

dialog.window?.setFlags(
            WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
            WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

这篇关于防止BottomSheetDialogFragment隐藏键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 23:10