Keyboard hides BottomSheetDialogFragment

后端 未结 6 1420
走了就别回头了
走了就别回头了 2020-12-04 13:22

There are more fields below the keyboard. This happened when i updated the support library. I know it\'s Kotlin but it looks almost the same as java. How do I fix this issue

6条回答
  •  被撕碎了的回忆
    2020-12-04 14:22

    I tried all of answers in this topic but nothing helped. I looked through many sites and found only one solution that working for me.

     override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
        val dialog = super.onCreateDialog(savedInstanceState)
    
        dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
        dialog.setOnShowListener {
            Handler().post {
                val bottomSheet = (dialog as? BottomSheetDialog)?.findViewById(R.id.design_bottom_sheet) as? FrameLayout
                bottomSheet?.let {
                    BottomSheetBehavior.from(it).state = BottomSheetBehavior.STATE_EXPANDED
                }
            }
        }
    
        return dialog
    }
    

    Original solution

提交回复
热议问题