Android: How to push button above soft keyboard

Xander picture Xander · Mar 10, 2013 · Viewed 60.3k times · Source

I've got a "save" button which I want to push up together with the soft keyboard. So when the user clicks an EditText in my layout, then the button has to stay above the keyboard. Now the button becomes hidden underneath the keyboard. How do you do this?

Thanks in advance!

Answer

Intathep picture Intathep · Mar 10, 2013

You need to set your keyboard's input mode to adjustResize. You can do this adding the following line to your activity's attributes in the manifest:

    android:windowSoftInputMode="adjustResize"

Here's an example of the attribute added in the activity:

<activity 
     android:name=".activity.MyActivity"
     android:windowSoftInputMode="adjustResize">
</activity>