软键盘显示时如何防止窗口大小调整和重新布局

dre*_*ale 6 keyboard android resize

我在一个活动中显示一个编辑对话框,当软键盘显示时,活动的窗口将调整为太小,看起来很糟糕. 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.

我试图在清单中使用android:windowSoftInputMode ="xxxxx",但是没有一种模式适合我的情况.我也发现了类似的问题,但它并没有解决我的问题.

编辑:我已经尝试过setImeOptions,getWindown().setFlags但它仍然没有奏效,任何建议将非常感激.

EDIT2:我在3.0中尝试过,使用android:windowSoftInputMode ="adjustNothing",它工作得很好,但我怎么能在2.3上实现呢?

thr*_*n19 14

在AndroidManifest.xml中为您的Activity添加此属性:

android:configChanges="orientation|keyboardHidden|screenSize"
android:windowSoftInputMode="stateUnchanged|adjustPan"
Run Code Online (Sandbox Code Playgroud)


dre*_*ale 1

我找到了避免该问题的方法,但只是避免,仍然想知道android 2.3中的解决方案。

之前,我在 XML 中从上到下布局控件,如下所示:

<ToolBar android:id="@+id/blabla"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" />
Run Code Online (Sandbox Code Playgroud)

因此,当键盘显示时,活动的窗口会调整大小,因此工具栏会被推动,这看起来不太好。

现在,我从顶部布局控件,通过窗口仍然调整大小,但是工具栏和其他控件不会被推送,它们只是在显示软键盘时布局到窗口之外。