1.布局文件为EditText添加下面属性 android:focusable="true" android:focusableInTouchMode="true"
2.代码中 为EditText设置以下属性即可
//打开软键盘
private fun showSoftInputFromWindow(editText: EditText) {
editText.requestFocus()
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
}