반응형
fun hideKeyboard(act: Activity?, edit: EditText?) {
if (edit != null) {
val inputManager = act?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.hideSoftInputFromWindow(edit.windowToken, 0)
}else{
if (act != null && act.currentFocus != null) {
val inputMethodManager = act.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(act.currentFocus!!.windowToken, 0)
}
}
}
fun showKeyboard(act: Activity?, edit: EditText?){
if(edit != null){
val inputManager = act?.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
inputManager.showSoftInput(edit, 0)
}else{
if (act != null && act.currentFocus != null) {
val inputMethodManager = act.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.showSoftInput(act.currentFocus, 0)
}
}
}
가로모드 시 이상한 키패드가 같이 올라오는 것을 볼수있다.
<EditText
android:id="@+id/et_search"
android:layout_width="0dp"
android:layout_height="match_parent"
android:paddingStart="16dp"
android:paddingLeft="@dimen/text_margin"
android:hint="검색"
android:imeOptions="flagNoExtractUi"
android:inputType="text" />
제조사에서 키보드를 불렀을때 강제로 자기들 키보드 editerea를 넣어주는데
이때 imeOptions를 flagNoExtractUi하면 된다.
반응형