[英]Prevent BottomSheetDialogFragment from hiding keyboard
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.如果我在当前活动/片段中打开了键盘,当我显示 BottomSheetDialogFragment 时,键盘会被解除,但我希望键盘保持在 BottomSheetDialogFragment 后面的背景中。 Is there a way to keep keyboard opened behind bottomSheetDialogFragment when I show the BottomSheetDialogFragment and prevent keyboard from being dismissed?当我显示 BottomSheetDialogFragment 并防止键盘被关闭时,有没有办法让键盘在 bottomSheetDialogFragment 后面打开?
I am showing the BottomSheetDialogFragment like this:我像这样显示BottomSheetDialogFragment:
modalBottomSheet.show(
(activity as AppCompatActivity).supportFragmentManager,
ModalBottomSheet.TAG + System.currentTimeMillis().toString()
)
I figured it out.我想到了。 In your BottomSheetDialogFragment's subclass, in the method: override fun setupDialog(dialog: Dialog, style: Int), do:在您的BottomSheetDialogFragment 的子类中,在方法中:override fun setupDialog(dialog: Dialog, style: Int),请执行以下操作:
dialog.window?.setFlags(
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.