0

First of all this question is not about how to hide keyboard programmatically.

We all know that we can get keyboard to appear automatically for EditText by getting focus on start and android:windowSoftInputMode="stateVisible".

Question: I have an EditText in a Fragment being focused and keyboard is shown. I navigate to another Fragment and the keyboard remains shown. How can i get the keyboard to hide automatically when the EditText (that the keyboard is for) is no longer visible?

Yes i could have hide the keyboard programmatically but i can't shake off the feeling that there must be a way to dismiss the keyboard automatically when it can be shown automatically.

Weizhi
  • 977
  • 6
  • 20
  • are you talking about edittext visibility ? or you want when fragment is finished? – Quick learner Mar 17 '18 at 18:50
  • @quicklearner i am talking about keyboard being automatically dismiss when `EditText` is "no longer visible on screen" in a very loose sense. Technically it can be due to a variety of reason 1) visibility set to `INVISIBLE`, 2) visibility set to `GONE`, 3) `EditText` no longer in view hierarchy (e.g. fragment finish), 4) `EditText` goes out of screen (e.g. scrollview). I am interested in any ways that Android framework can handle some/all of these scenario. – Weizhi Mar 18 '18 at 00:52

0 Answers0