Android soft keyboard hides edit text field with windowSoftInputMode set

GIZNAJ picture GIZNAJ · Mar 13, 2016 · Viewed 8.2k times · Source

Some of my activities are made up of 3 fragments in a vertical layout (Top, middle and bottom)

The middle fragment is the only one that is wrapped in a scrollview. The top and bottom fragments are static. The bottom fragment has the edit text controls for user input. Weighting for fragments from top to bottom are .1, .6 and .3

When the soft keyboard comes up for user input, it covers the edit text fields the user needs to enter text in. It seems that the fragments move up, but not enough and half of the bottom fragment is covered by the keyboard. I used multiple switches with the windowSoftInputMode attribute and none seem to work.

windowSoftInputMode="adjustResize|stateHidden" windowSoftInputMode="adjustPan"

How can I guarantee that at least the bottom fragment is completely visible when the soft keyboard is displayed? What do I have to do?

Answer

GIZNAJ picture GIZNAJ · Apr 17, 2016

I got this working fully with XML. If you are looking to:

  • Not have the soft keyboard come up when an activity starts
  • Not have the soft keyboard hide any editText on the page (even with fragments)

Enter the following in your AndroidManifest.xml file for the activity that you wish to do the above to.

android:windowSoftInputMode="stateHidden|adjustPan"