Reputation: 1095
I'm hiding a keyboard from a DialogFragment using this code...
etCustomerLookup.hideKeyboard()
Extension...
fun View.hideKeyboard() {
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(windowToken, 0)
}
This is what I'm seeing....
Update: Even after commenting out the hideKeyboard() line, it changes nothing, still get the faded keyboard. Another note - all of the buttons "under" the faded keyboard are still accessible.
Upvotes: 2
Views: 139
Reputation: 4080
Please try these two,
fun hideKeyboard(activity: Activity) {
val imm: InputMethodManager = activity.getSystemService(AppCompatActivity.INPUT_METHOD_SERVICE) as InputMethodManager
//Find the currently focused view, so we can grab the correct window token from it.
var view = activity.currentFocus
//If no view currently has focus, create a new one, just so we can grab a window token from it
if (view == null) {
view = View(activity)
}
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
fun hideKeyboardFromWindow(activity: Activity) {
val view = activity.findViewById<View>(R.id.content)
if (view != null) {
val imm = activity.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
}
Upvotes: 0
Reputation: 816
I think you are using a window that appears on top of the keyboard, and because your view has transparency this thing happens.
Upvotes: 1