In response to a reader's question, William J. Francis helps clarify the difference between Android's software input values "adjustPan" and "adjustResize."
Last week, I wrote about forcing Android's virtual keyboard (VKB) to show or hide via the IME Manager. After publishing the article I received a question about the difference between Android's software input values "adjustPan" and "adjustResize." Both of these values are specified in the manifest, and apply to the activity level attribute, "windowSoftInputMode."
Google defines the difference as follows:
- 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.
So what exactly does all that mean? While I get some idea when I read something the way I best learn is to try for myself.
Figure A is a simple layout with an edit text attached to the top and bottom of the parent view.
Figure B is the same layout as in Figure A with the VKB showing. The "windowSoftwareInput" attribute is set to "adjustPan" in this case.
Figure C is the same layout and VKB shown in Figure B but with the "windowSoftwareInput" attribute changed to "adjustResize."
There we have it. In Figure B Android scrolls the layout in such a way that the current input field can be seen even though the VKB is obscuring a portion of the screen. In Figure C the entire parent layout is condensed to make room for the VKB. For additional "windowSoftwareInput" values, take a look at the manifest topic in the developer's guide.