问题表象:

今天在移植部分代码时,出现了输入法的menu栏不显示的问题。如上图图二。
细心观察会有3处不同:
- 输入法栏显示不全
- actionBar的头部不显示问题。
- 图1ListView没有滚动,图2整体向上滚动
问题原因
activity配置如下
<activity
android:name="***.PostDetailActivity"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Translucent.NoTitleBar.FullScreen"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize">
</activity>
layout 配置文件结构如下:

代码移植后,layout配置文件未做大的修改,代码Activity,fragment也未做输入法相关的改动。
细心翻看代码提交记录,还有点点经验,感觉可能是manifest配置文件的问题,于是做了比较,果然android:theme
不同。怀疑是这个原因导致的。
由于使用了android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
和adjustResize
,
fullScreen
属性导致adjustResize
参数不起作用。
深挖 问题原因
请看文档:
https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_FULLSCREEN
FLAG_FULLSCREEN
added in API level 1
int FLAG_FULLSCREEN
Window flag: hide all screen decorations (such as the status bar) while this window is displayed. This allows the window to use the entire display space for itself -- the status bar will be hidden when an app window with this flag set is on the top layer. A fullscreen window will ignore a value of SOFT_INPUT_ADJUST_RESIZE for the window's softInputMode field; the window will stay fullscreen and will not resize.
This flag can be controlled in your theme through the windowFullscreen attribute; this attribute is automatically set for you in the standard fullscreen themes such as Theme_NoTitleBar_Fullscreen, Theme_Black_NoTitleBar_Fullscreen, Theme_Light_NoTitleBar_Fullscreen, Theme_Holo_NoActionBar_Fullscreen, Theme_Holo_Light_NoActionBar_Fullscreen, Theme_DeviceDefault_NoActionBar_Fullscreen, and Theme_DeviceDefault_Light_NoActionBar_Fullscreen.
意思就是使用FullScreen后,SOFT_INPUT_ADJUST_RESIZE
将不在起作用。
若你必须使用FullScreen,可以参考下面给出的解决方案:
http://stackoverflow.com/a/30019136/325479
这里也有这个问题的很多讨论:
https://code.google.com/p/android/issues/detail?id=5497&q=fullscreen&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars