Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android resize layout when keyboard appears

Tags:

java

android

I would like to reposition layout when keyboard appears, for example when editing a text field, in order to get visibility on focused field. I tried windowSoftInputMode but I cannot get any difference. How to reach it? Thank you.

<activity 
            android:name="com.xxxx.projecte1.TabBar_Activity"      
            android:theme="@android:style/Theme.NoTitleBar"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustResize"
           />
like image 319
Jaume Avatar asked Jul 10 '12 15:07

Jaume


People also ask

What is window soft input mode?

Posted on October 25, 2010 by Lars Vogel. Android has the so-called Input Method Framework to support different input methods, e.g. keyboard, soft-keyboard, handwriting etc. If the soft-keyboard is used it is diplayed at the bottom of the screen once the user select an text view to edit it.


1 Answers

For anyone else who might have a similar problem:

What fixed it in my case was just putting

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

into my activity's onCreate method.

Without any xml changes whatsoever, since those did not work for me whatsoever, but this worked right away like a charm. Although an xml solution seems nicer to me, even the same parameter did not work.

Sharing it since I did not find a quick and easy fix myself online.

like image 54
Levite Avatar answered Oct 20 '22 16:10

Levite