android:windowSoftInputMode="stateAlwaysHidden|adjustPan" doesnt work on all devices

ChuckKelly picture ChuckKelly · Sep 26, 2013 · Viewed 8.5k times · Source

As many do , I ran into the problem of the softinput covering my send buttons so I did some searching and found the accepted way of fixing this issue is "android:windowSoftInputMode="stateAlwaysHidden|adjustPan"

and this works great on my device, but when I try it on my girlfriends phone it doesnt work. I see the dialog lift a little before the input shows up on screen , but not much and the send button is still covered. Why would this work on some devices , but not all?

Answer

Alec Teal picture Alec Teal · Sep 26, 2013

Messing with the onscreen keyboard is difficult at best because on the one hand:

It's supposed to be where it is, that way users expect it, it's consistent, very important in UI design

BUT

It can get in the way.

The solution (based on the Android design guidelines, experience and feedback and so forth) is not to faff with it too much, you can have basically the following kinds of behavior:

*Pops up when activity starts (which happens if the activity has an input)

*Doesn't pop up when activity starts (despite the first input having focus <-- good) but will when the user taps.

It's good to dismiss the keyboard when the user is done, that is have the "enter button" take them to the next entry, if there's none left, hide it, if it's some sort of data capture form that validate as they go along, if not don't do this because they might press back in an attempt to get it up.

Addendum I

"adjustResize"

The activity's main window is always resized to make room for the soft keyboard on screen.

"adjustPan"

The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

From the documentation here: http://developer.android.com/guide/topics/manifest/activity-element.html

Difference between adjustResize and adjustPan in android?

See there for more.

It's difficult to pan correctly because the layout of the activity can be many things, it could scroll to the left, it could all be relative, it's not one strip where it need only jump up and down, some things also have more than one solution, more than one way to pan so it is visible. You haven't really described what doesn't work btw. I'm trying to explain the issues of what I think you want.

Does this help?