0

I always thought the android keyboard would hide automatically when i touch outside of an EditText. I have several text inputs in my application. Only the first has the tag

<requestFocus />

in the xml layout definition. I have no other implementations influencing the keyboard (or at least i think i dont have any). The only maybe important thing is that i use FragmentActivity and Fragment from the support package only.

When i start my app the keyboard pops up correctly with the correct EditText in the focus. When i rotate my device my keyboard gets hidden (i really dont know why). When i rotate back it gets shown again. And when i click outside the EditText on the layout itself or on a button or something, the keyboard isnt hiding but i really want it to.

I thought there would be no additional coding needed for this purpose.

Mulgard
  • 8,305
  • 26
  • 110
  • 205
  • Take a look at http://developer.android.com/training/keyboard-input/visibility.html – bwegs Nov 30 '14 at 18:34
  • Yes and i read "When input focus moves into or out of an editable text field, Android shows or hides the input method (such as the on-screen keyboard) as appropriate." which is not the truth in my case. – Mulgard Nov 30 '14 at 18:35
  • `Note: Once the input method is visible, you should not programmatically hide it. The system hides the input method when the user finishes the task in the text field or the user can hide it with a system control (such as with the Back button).` – bwegs Nov 30 '14 at 18:44
  • Yes i dont hide it programmatically. So there is no general functionallity for hiding the keyboard when the user touches outside of an edittext? – Mulgard Nov 30 '14 at 18:46
  • I'd try something like this - http://stackoverflow.com/a/7696791/745750 – bwegs Nov 30 '14 at 18:56
  • I dont like such hacky things. they dont feel like clean code for me. i would rather accept that i cant hide the keyboard automatically when user touches outside. – Mulgard Nov 30 '14 at 18:58

1 Answers1

1

I have found my root reason, it is because the host activity set android:windowSoftInputMode="stateHidden|adjustResize" , if remove it question will be solved, hope it works to you

newszer
  • 390
  • 2
  • 16