Hide to show and hide keyboard in DialogFragment

后端 未结 8 2331
花落未央
花落未央 2021-02-08 03:57

In my dialog fragment, I am able to show the keyboard using

getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT STATE_VISIBLE);
         


        
8条回答
  •  眼角桃花
    2021-02-08 04:43

    I found only one fully working approach if you want to show keyboard when dialog is shown and hide keyboard when dialog is dismissed

    
    

    And then you should use the theme above inside your DialogFragment

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setStyle(STYLE_NORMAL, R.style.InputDialog)
    }
    

提交回复
热议问题