views:

243

answers:

2

Hi,

In my android application, I have an EditText. When I click in this field, the soft keyboard appears, expanding from the bottom of the screen. It seems to actually modify my layout, pushing contents upwards. When I dismiss the keypad, it retracts, and I see my layout re-expand to take up the space it previously occupied.

Is there a way to get the keyboard to simply appear "on top" of my layout, so that I don't get this somewhat unpleasant relayout animation? The EditText is pinned to the very top of the screen, so I don't have to worry about the keypad hiding it.

Thanks

A: 

By default, Android should be using "Pan and Scan", which would work more or less how you described. The keyboard is displayed over your view, and you can scroll your view in the background. If you override the windowInputMode for you Activity, or Android determines that your Activity is resizable (because of the presence of a resizable field... ListView, ScrollViews, etc), it may resize your view instead, and it sounds like that's what you're running into. To force it to Pan and Scan try adding:

android:windowSoftInputMode="adjustPan"

as an attribute to the Activity element in your xml layout.

There's a third option as well. You can specify that when an EditText is selected it will be edited in full screen mode. The other controls in your view will be hidden, the user will be presented with just the keyboard, an EditText control, and optionally some other limited controls. If your EditText doesn't require a lot of context from other elements of your view, it may prevent a cleaner user interface. For more details, see: http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html

A: 

Add:

android:windowSoftInputMode="adjustResize"

to your activity attr in manifest.xml. Hope it will help.

herbertD