How to prevent window resizing and relaying when displaying a soft keyboard

I show the edit dialog in action, when the soft keyboard is displayed, the activity window will be changed to too much, which looks awful. I don't want the window of the activity be resized and layout. I just want the keyboard can cover on the activity window and the dialog move to the top so that soft keyboard have room to show.

I tried using android: windowSoftInputMode = "xxxxx" in the manifest, but there is not a single mode that matches my situation. I also found a similar question , but it did not solve my problem.

EDIT: I tried setImeOptions as well as getWindown().setFlags , but it still didn't work. Any advice would be greatly appreciated.

EDIT2: I tried in 3.0 and used android: windowSoftInputMode = "adjustNothing", it worked fine, but how can I implement this on 2.3?

+6
source share
2 answers

I found a way to avoid the problem, but just avoiding it, I still want to know the solution in Android 2.3.

I used to build controls in XML above and below, like this:

 <ToolBar android:id="@+id/blabla" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" /> 

So, when the keyboard is displayed, the activity window changes, so the ToolBar is pressed, which does not look very good.

Now I am arranging the controls on top, it is still resizing through the window, but the ToolBar and other controls will not be pressed, they just exit the window when the soft keyboard is displayed.

+1
source

Add this property to AndroidManifest.xml for your activity:

 android:configChanges="orientation|keyboardHidden|screenSize" android:windowSoftInputMode="stateUnchanged|adjustPan" 
+14
source

Source: https://habr.com/ru/post/920326/


All Articles