Developer

Pro tip: Make sense of pan vs. resize in the Android manifest

In response to a reader's question, William J. Francis helps clarify the difference between Android's software input values "adjustPan" and "adjustResize."

android-logo-generic-hai.jpg

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 A

androidvkb1092514.png

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 B

androidvkb2092514.png

Figure C is the same layout and VKB shown in Figure B but with the "windowSoftwareInput" attribute changed to "adjustResize."

Figure C

androidvkb3092514.png

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.

About William J. Francis

William J Francis began programming computers at age eleven. Specializing in embedded and mobile platforms, he has more than 20 years of professional software engineering under his belt, including a four year stint in the US Army's Military Intellige...

Editor's Picks

Free Newsletters, In your Inbox