简体   繁体   English

防止 BottomSheetDialogFragment 隐藏键盘

[英]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.

相关问题 如果键盘可见,则防止关闭 BottomSheetDialogFragment - Prevent dismissal of BottomSheetDialogFragment if keyboard is visible 如何防止键盘隐藏? - how to prevent keyboard from hiding? 防止软键盘在单击按钮时隐藏 - Prevent Soft Keyboard from hiding on button click 防止在Android上隐藏软键盘的按钮 - Prevent Buttons From Hiding Soft Keyboard On Android 键盘位于EditText字段上,因此将其隐藏。 如何防止键盘隐藏EditText字段? - The keyboard is coming upon the EditText field & thus hiding it. How to prevent the keyboard from hiding the EditText field? Android:防止edittext隐藏在键盘后面而不更改清单 - Android : prevent edittext from hiding behind keyboard without changing manifest 防止键盘隐藏警报对话框的提交按钮 - Prevent Keyboard from hiding the submit button of alert Dialog 如何防止自定义DialogFragment在显示时隐藏键盘 - How to prevent custom DialogFragment from hiding keyboard when being shown 键盘隐藏BottomSheetDialogFragment - Keyboard hides BottomSheetDialogFragment 如何防止 BottomSheetDialogFragment 在导航到另一个片段后关闭? - How to prevent BottomSheetDialogFragment from dismissing after a navigation to another fragment?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM